Using Sendmail on development server

  • Posted August 17, 2014

I’m in the process of moving a site from GoDaddy to a LAMP Ubuntu 14.0.4. on DigitalOcean. So far everything is working except for mail.

I installed Sendmail, but when I test the contact form on the site (which uses PHPMailer) it fails to reach the recipient. When I look in /var/spool/mail/root I see messages like this:

The original message was received at Sat, 16 Aug 2014 23:56:55 -0400
from localhost []

   ----- The following addresses had permanent fatal errors -----
    (reason: 550 5.2.0 <www-data@store> From: Domain is invalid. Please provide a valid From: IB506  <>) 

I’m leaving the email accounts for the website at GoDaddy, so I’m not sure what to try next. Can someone point me in the right direction?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The problem is the “www-data@store” address that apache is trying to send the email from. I run into this all the time and there is always a different solution. Usually it is a programming issue.

Basically, you have to make sure that the ‘From’ address for the email is a valid and locally resolvable email address. So, depending on what software you are using to send the email the fix will vary.

If it’s something you have developed in PHP yourself, make sure you set the ‘From’ header in the $additional_headers parameter. eg:

$from = '';
$additional_headers = array('From' => $from);
mail('', 'Test Email', 'This is the content', $additional_headers);

If that doesn’t work, you can also try setting it as an additional_parameter and send the sendmail -f argument that will explicitly set the from address. This is usually a catchall solution. eg:

$from = '';
$additional_headers = array('From' => $from);
mail('', 'Test Email', 'This is the content', $additional_headers, '-f ' . $from);