Debugging mail delivery
Table of Contents
If you find that emails aren't being delivered, there are some basics to check first to rule out your application and your DNS settings before escalating an issue with the support team.
Check if PHP is sending mails
Using a standalone PHP script (to rule out Magento/WordPress etc.), create a simple PHP file in the document root with your email as the recipient and view it in a web browser (replace the domain and email address with your own respectively),
Eg. https://www.example.com/mail.php
<?php var_dump(mail('info@example.com', 'info@example.com', 'info@example.com'));
- If you see
bool(false)
, something fatal has gone wrong and it is best submitting a support ticket - If you see
bool(true)
displayed on screen but no email in your inbox, it is likely SPF or DKIM - If you see
bool(true)
displayed on screen and an email in your inbox confirms that PHP is sending emails - If you see
bool(true)
displayed on screen and an email in your inbox, but you still don't see your emails from Magento, its likely Magento is misconfigured
Magento is misconfigured
Some emails in Magento are sent immediately, some are sent on a schedule, initiated via cron.
- If no emails at all are being sent by Magento then it is highly likely that Magento is misconfigured, perhaps a hardcoded mail server that doesn't exist or a 3rd party module trying to handle its own mail delivery.
- If some emails are sent, but not all, check that your cron is properly configured.
Mail quality issues (DNS, SPAM etc.)
In the event of DNS (DKIM or SPF) being a likely cause for undelivered mail, it is recommended to send a test email (from your application) to the grading service at https://mail-tester.com - this will provide valuable insight into mail quality issues.
Viewing mail logs
To access mail logs, you can view them either,
-
By File: In
/microcloud/logs_ro/mail
Eg. To find emails sent to info@example.com on 16-08-2018
zgrep info@example.com /microcloud/logs_ro/mail/postfix-2018-08-16*
2018-08-16 17:12:46 UTC /smtp[4965]: DC1DAA6176: to=info@example.com, relay=mx1.emailsrvr.com[184.106.54.1]:25, delay=1.5, delays=0.07/0.01/0.96/0.43, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as F2/7B-22170-D80B57B5) 2018-08-16 17:12:46 UTC Aug 16 18:12:46 mail1 postfix/smtp[4965]: DC1DAA6176: to=info@example.com, relay=mx1.emailsrvr.com[184.106.54.1]:25, delay=1.5, delays=0.07/0.01/0.96/0.43, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as F2/7B-22170-D80B57B5)
-
By GUI: In Kibana
Eg. Using the search term
msg:info@example.com
In particular, you are looking at the status=sent
line, confirming the mail was delivered successfully. If the mail is marked as sent, but you didn't receive it, then its likely a DNS issue (DKIM or SPF).