Store
Community Documentation

v3 Knowledgebase

Problems with the mail


Users are not getting mail from the site


Mail is a beautiful thing, when its set up properly.
Since the beginning of phpfox we have faced mail barriers, support requests for clients whose site cant send emails to the most popular clients, this has led us to understand better how internet mailing works.


Methods for sending Mail


There are basically 2 ways of sending mail from Phpfox, "mail" and "smtp".


  • Mail

This actually refers to the php mail function. Honestly we had to look at the code of this function (C language) to see how it works and now we understand why it fails so much. As it turns out the mail function uses a pipe (which is like a socket with its differences) to send the message to the recipient's mail server, there are no fault controls, no queue... nothing more than a one time communication between two computers.
It is prone to internet packet loss, bad mail management and other problems, but for some it works just fine.


  • SMTP

SMTP stands for Simple Mail Transfer Protocol, it has its roots to arguably as far as 1971 so you can expect a much more robust and stable service here. This is the preferred method for sending email, you can have your Google Apps account send mail for you but most Hosting Companies provide a SMTP server for you. On Ubiquity Hosting the way their mail accounts work is by means of you creating a mail user and you use that mail user as your credentials when setting up mail on phpfox.


Using SMTP


With many hosting providers you are given also email accounts, if they support SMTP (most do) you can create a mail user from your CPanel, Plesk or similar and use that account with phpfox to send mail with SMTP, the email address is usually the username but you should confirm with your hosting company about the mail host, it can be something like: mail.yoursite.com or it can be something completely different. In any case talking with your hosting company is a good idea to get the credentials right.


Headers


No matter which method you choose there is a portion of the message called headers. the headers specify many things, between them the importance or priority of the message, who sent the message, the message id and many others.

So, now that you have a little better understanding of the options at hand we need to mention that mail is handled internally in phpfox by a third party package called phpmailer. It is considered as the best mail handling library available and its free. It takes care of all the headers and formatting and standards compliance so your mail goes out just as perfect as it can be.

Here is the whole picture:


  1. In your site someone triggers an action that sends an email, the phpfox script gets this action
  2. The phpfox checks the users that will receive the mail and sets their emails
  3. The phpfox script sends the message, the from and the to fields to phpmailer, it also sends the character set (UTF-8 or else) and line breaking settings as well as smtp settings if available and the method to use (smtp vs mail).
  4. Phpmailer takes all those parameters and sends the mail.

Thats as far as we're concerned here (the details of how it connects to the other server are not relevant right now) and this is why it gets difficult to say this, if your mail does not come out, there is very little responsibility on the Phpfox end, I would dare to say that 10% or lower is actually done on the phpfox side.
There are of course ways to check if your mail is working, one is by using another script to check if it works, a simple php line like this would test if the "mail" method is working for this one case:


<?php $bSent = mail('youraddress@yourmailprovider.com','subject', 'message'); var_dump($bSent); ?>

it would output true if mail was sent and false if it wasnt and here's one caveat, the fact that it got sent, doesnt mean it got received. Mail Clients like Yahoo!, Hotmail, GMail, etc, do not return right away if the message was received properly or not, they can place the message in a queue to be checked and by then the communication between the servers has been closed already. But if you test this and you actually got the test email (when checking your inbox or spam folder) then you know this method works (or at least worked for this one case).


SPF Records


Among the many reasons why a mail could not make it to the recipients' inbox is that it got marked as SPAM, each mail client has its own rules on defining what SPAM is but perhaps the most important one is the SPF Record.
In internet there are translators that say "the address www.site.com is the computer 219.219.219.219", thats an IP number, unique to your server and the way in which internet computers are identified, you can think of it like your house address, theres only one address for each house. In these servers you can host a small record that says "the server 219.219.219.219 is the only server that sends mail from www.site.com". Mail clients check on these records and if they find one they compare it to the message they just received.
Implementing an SPF record is free, and your hosting company can help you with that. This is the official site for the openspf project.


Checking your SPF records


When having problems with mail you really want to check if your domain has a SPF record, the following tools will help you to identify whether you have one and if its properly set up.


  1. http://www.openspf.org/Why
  2. http://www.kitterman.com/spf/validate.html



DKIM



Additional to SPF there is another validation tool called DomainKeys Identified Mail. Google Mail defines it as "DKIM (DomainKeys Identified Mail) is a way to digitally sign messages and verify that the messages were sent by a particular domain. It works like a wax seal on an envelope, preventing messages from being tampered with.".
More information
http://www.dkim.org/


Check your DKIM



Go here, in the "Selector" field enter "pm" (without quotes") and in the domain name the domain you want to check.

​​​​​