Troubleshoot - Email Problems

From Zen Cart(tm) Wiki

Jump to: navigation, search

Contents

Troubleshooting Email Problems in Zen Cart™

Zen Cart™'s email infrastructure is largely dependent on the services available to the computer operating as your webserver. This includes internet connection issues, available ports, as well as PHP configuration options and the programs/services running on your server.


Zen Cart™ Email Infrastructure Explained

Here's how it works:

  1. Admin and Store both use the same infrastructure.
  2. Zen Cart™ uses phpMailer for sending mail in the v1.3.x series.
    (Prior to v1.3, Zen Cart™ used a mishmash of inherited code from osCommerce that met with mediocre success and needed a huge facelift. So it was switched to the popular phpMailer class after successful testing on numerous sites.)
  3. Wherever an email is sent, it is initiated via zen_mail() which is in the /includes/functions/functions_email.php. This builds the email object according to all your settings in Admin > Config > Email options.
    • transport method: PHP, smtp, sendmail, sendmail-f, smtpauth, etc.
    • CR/LF settings
    • charset
    • mime type
    • sent to, sendfrom
    • ... everything from that section, really.
  4. Then it hands the email off to phpMailer to send it.
    • If the transport is "PHP", then the server's PHP configuration takes over entirely, using whatever PHP has been configured to use.
    • If the transport is a sendmail function, then the server attempts to use the sendmail program on your webserver.
    • If the transport is SMTP/SMPTAUTH, then direct communication with the specified mailserver is initiated.
  5. If email archiving is enabled, the email is stored to the archive table.

Done.

That's it.


Prerequisites

  1. Your webserver must have a mail service enabled. For Linux/Unix hosts, this is typically done via sendmail or exim or qmail daemons. On Windows™ servers, this may be done via services offered with IIS.
  2. Your webserver must allow email connections from PHP.
  3. If you are using sendmail options, then the PHP configuration for sendmail functions must be configured properly on the server.
  4. You must have an unrestricted connection to the mailserver you're sending through.
    • If you are running from a home-based server (ie: for testing), note that your ISP may automatically have port 25 blocked so that you have to send mail through their server. In this case, use SMTP for your transport method, and supply your ISP's mailserver as your SMTP host.
    • If your webhost mailserver is reachable on another port, supply that port number in the SMTP settings.


Diagnosing Problems

  1. change transport methods (ask your host what's best ... they should know how they've configured your server).
    • NOTE: PHP or smtpauth or sendmail-f are less likely to end up getting treated as spam.
  2. change send-from email addresses (Admin->Configuration->Email Options).
    • MAKE SURE THE ADDRESS IS VALID.
    • It is recommended to use an email account linked to the same domain name as your store. Attempting to masquerade with a different email address makes your emails prime candidates for being treated as junkmail, and thus not delivered.
  3. change send-to email addresses ... DO NOT TEST USING FREE MAIL SERVICES ... your mail is often dropped to a junkmail spot.
  4. be sure there are no embedded carriage returns in your send-to email addresses (see http://www.zen-cart.com/forum/showthread.php?t=86423 for details)
  5. check your junkmail settings.
  6. research whether your mailserver or hosting company is blacklisted (you can check http://www.mxtoolbox.com/blacklists.aspx or google for smtp blacklist for additional resources)
  7. try setting the option for Emails must send from known domain? to true. This causes the email "sender" address to be more aligned to your own website, and thus less likely to be rejected while processing.
  8. check whether the email archives are showing the sent messages (there's an archive reader in the Downloads area under Admin Tools)
  9. try testing with MIME HTML emails OFF, since many spam filters block HTML-formatted messages before they even get out the gate.
  10. check the mailserver logs ... is it complaining about something, either inbound or outbound?
  11. for kicks, get the webserver/mailserver rebooted and dump all the logs ... just maybe something's runamuck in there ...
  12. Try enabling Email Archiving (Admin->Configuration->Email Options->Email Archiving). Then install the email archive manager from the Zen Cart™ Downloads section (in admin tools), and confirm that the emails are actually being sent from Zen Cart™. If it's in the archive, it was handed off to the mailserver. Once the email leaves Zen Cart™, it's at the mercy of your mailserver.
  13. Look at your raw/full email headers. Does the "from" address appear to be a "nobody@xxxxxxx" address? Some hosts block these. The "email must send from known domain" setting is designed to counteract this. The SMTPAUTH setting also helps to work around this.
  14. This is RARE: If using "sendmail" and your "sendmail" path on your webserver is not the default of /usr/sbin/sendmail then you can override the default by adding a definition for it in a new file on your server: /includes/extra_datafiles/email_sendmail_override.php ... create a define for EMAIL_SENDMAIL_PATH and point it to the actual sendmail path for your particular host. This should not be necessary, and usually using "PHP" as transport method will correct it without making this edit.
  15. Does your server require 7bit mail encoding instead of the default 8bit? If so, edit the /includes/extra_configures.email_use_8bit.php file and put // before the define statement there.

If the email doesn't get to its destination, then usually the problem is a misconfiguration of the MTA or the host is blacklisted somewhere, or ports are blocked or ... well ... the probable causes are for a system administrator to understand.

For IN DEPTH ASSISTANCE on email matters, see Troubleshoot_-_Understanding_Causes_Of_Lost_Emails


Questions for your Hosting Company

Have you asked your hosting company what the right configuration is for your server to send mail most appropriately?

As far as Zen Cart™ is concerned, you have these options. Ask your host what they require:

  1. Mail Transport ... select from PHP, sendmail, sendmail-f, smtp, smtpauth
  2. Emails must send from known domain ... true/false
  3. E-Mail Linefeeds ... LF for Linux/Unix hosts, CRLF for Windows hosts

If your "contact us" emails are not arriving at the desired destinations, try emptying the "contact us pulldown" list. This will force it to use your Store Owner email address and bypass the occasional confusion encountered with properly formatting addresses for the pulldown list.

As mentioned earlier, if the emails are showing in the archive log (assuming you've enabled it), then Zen Cart™ is generating the message and handing it off to your webserver to send. If it's not being delivered, then either your webserver is dumping it, or the recipient is not getting it, possibly due to frequent spam from your webhost or other reasons. Perhaps your hosting company will offer you some assistance or at least explain how their servers are configured so that you can determine the right setting for your hosting environment. They know your server better than anyone.

Ask your host whether your/their mailserver is blacklisted by anyone. If so, try to get the blacklisting removed.

Is your account's SPF record correct?

AOL and Hotmail dump emails originating from server/client IP addresses that fail DNS reverse lookup. You should talk to your webhost to ensure that your webserver and hosting account / domain are properly configured with a PTR or DNS reverse lookup.

Using external SMTP mail servers

Some people prefer to use resources such as gmail or yahoo mail etc for sending their business emails. There are differing schools of thought about the merits of doing so. If you deem that this is the best practice for your business, the following information may be of help to you.

Yahoo Hosting

For those of you using Yahoo as a webhost doing a search in the Yahoo help pages for PHP/Perl set up may help. Also setting up a tmp file in your Yahoo account may shed a bunch of light on things and give you answers right away as to why the e-mail isn't sending.

  1. In your Yahoo control panel, check if the email address you are using is set as "Pop/Webmail", and not just "Mail Administrator". You may have to create a new one.
  2. The Zen Cart option Emails must send from known domain must be set to YES, and mail transport should be SMTPAUTH.
  3. Yahoo Outgoing (SMTP) Mail Server: smtp.mail.yahoo.com
  4. SMTP Port 25 or 587 (You MIGHT be able to use 465, but may have to check with tech support first.)

If you're hosting someplace other than Yahoo but trying to send email through your Yahoo email address, work with your hosting company to configure your DomainKeys and SPF settings to allow the emails to be accepted instead of being rejected as forged spam messages.

Google Gmail

Gmail wants an SSL/TLS connection, which is not offered by Zen Cart. Nevertheless, you may or may not have some success with the following:

Set up as SMTPAUTH, with your gmail username/password.

  • SMTP Host: smtp.gmail.com
  • SMTP Port 465 or 587

More technical information is available in Google's Help Center

You may have to have your host make some changes if you are using Google hosted mail.


GoDaddy Hosting Plans

  1. If using the default "PHP" setting for Email Transport method doesn't work, try the following:
    • Use "SMTP" for your Email Transport setting instead.
    • Set your SMTP Email Server address to: relay-hosting.secureserver.net
    • You can probably leave the SMTP mailbox and password fields blank
    • Set the "Emails must send from known domain" to yes. (This is required so that the GD mail servers don't reject your emails)
    • For your "Sent FROM" email address, use an email address that matches the domain name of your website. ie: if your website is www.abc.com, then use something like sales@abc.com as your Sent From email address (otherwise GD may reject your emails).
    • Do not send an email "to yourself", "from yourself" when testing.
  2. Set your Max Email limit:
    • If you have a GoDaddy hosting plan and plan to use it for sending emails from your Zen Cart site, you should check your email account list and set the "smtp relay transmissions per day" to the max of 250/day instead of the default of 0/day.


Preventing My Mail From Being Treated as Spam

The most common cause of email being treated as spam stems from how your webserver is configured to send mail. By default, PHP will appear as a user called "nobody@yourdomain.com" or something similar. Most spam filters will look at that and assume that those emails were generated by spam bots and thus the message is dumped without any further consideration.

Other causes include messages which have ALL UPPERCASE letters in their Subject field. Don't do that. You can usually set the subject line for individual emails in your Zen Cart language files.

  1. change your email transport method to "sendmail -f" or "SMTPAUTH". This will cause the messages to appear as they are coming from "you" instead of as coming from your server's PHP.
  2. the option 'Emails must send from known domain?' should be set to True. This will cause e-mail providers see that it is coming from some place legit and not filter it as spam. And, more specifically, your own webserver will not ignore it because it will now appear as legitimately coming from itself, rather than from a 3rd-party.
  3. AOL and Hotmail dump emails originating from server/client IP addresses that fail DNS reverse lookup. You should talk to your webhost to ensure that your webserver and hosting account / domain are properly configured with a PTR or DNS reverse lookup.

HTML-formatted Email in non-English Languages

The english HTML emails are built from the files in the /email folder. If you have other languages, you'll need to create your own HTML email template files and put them into subfolders named according to the 2-letter language code.

ie:

  • /email/de/
  • /email/es/
  • /email/fr/


Why Do Emails Not Show in HTML format?

HTML-formatted emails are SENT *only* when ALL of the following conditions are met:

  • HTML/MIME format is enabled in your admin
  • Customer has elected to choose HTML-formatted emails
  • You have the HTML email templates present in the /email/ folder of your site, and haven't changed permissions in any way that would prevent PHP from reading them (defaults are recommended)

Occasionally even though the email may be SENT in HTML format, it may ARRIVE without the HTML section displaying properly, for a few possible reasons:

  1. your hosting company's webserver stripped the HTML out because it appeared to violate a spam rule
  2. the recipient's hosting company stripped the HTML out because it appeared to violate a spam rule
  3. the recipient is using a free webmail-based email reader which alters the HTML content in a way that prevents your content from being displayed as desired
  4. you composed the email (altered the HTML in the template) to use advanced XHTML/CSS that's not supported by the recipient's email client
  5. the recipient is using an email program which doesn't render the HTML portion properly
  6. the recipient has changed their email program settings to disallow HTML content, either as a general rule or perhaps only from senders whom they've not whitelisted as known senders

Be sure to review the "Diagnosing Problems" section above for other tips related to potential delivery problems.