I am setting up a Science Fair in a Box server that uses apache2, PHP5, and sendmail (although we've uninstalled sendmail and installed postfix with no change in problem ) to send participants their login / registration number.

When the PHP mail() is called it has the properly formatted FROM: address but because sendmail authenticates and is receiving it from www-data@localhost it is stripping out the email address and replacing it with <@> which causes the mail to be sent but filtered out by any server it sends to.

Here is the PHP output verbatim as what is sent to PHP mail():

2018-01-23,1516725176,[email protected],[email protected],Registration for Kiwanis Southeast Alberta Regional Science Fair,We have received a request for the retrieval of your registration number from this email address.  Please find your existing registration number below Registration Number: 380285

This is the /var/mail/mail.log excerpt:

Jan 23 16:28:36 localhost sendmail[813]: w0NGSaU2000813: Authentication-Warning: seab-sciencefair.com: www-data set sender to @ using -f
Jan 23 16:28:36 localhost sendmail[813]: w0NGSaU2000813: from=@, size=259, class=0, nrcpts=1, msgid=<[email protected]>, relay=www-data@localhost
Jan 23 16:28:36 localhost sm-mta[814]: w0NGSasq000814: from=<>, size=575, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=ip6-localhost []
Jan 23 16:28:36 localhost sendmail[813]: w0NGSaU2000813: [email protected], delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30259, relay=[] [], dsn=2.0.0, stat=Sent (w0NGSasq000814 Message accepted for delivery)
Jan 23 16:28:36 localhost sm-mta[816]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Jan 23 16:28:37 localhost sm-mta[816]: w0NGSasq000814: to=<[email protected]>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120575, relay=gmail-smtp-in.l.google.com. [], dsn=2.0.0, stat=Sent (OK 1516724916 i8si684450iof.207 - gsmtp)

We have sent mail from the command line in the past so sendmail can send.

It is sending mail but the FROM: needs to be changed. So I interpret this as either a configuration problem or an apache2 alias problem.

I note this server is located on digitalocean, is this a cloud configuration issue?

What should I try next? Which software is the likely culprit?

  • I'd strongly urge you to use a class like SwiftMailer instead of raw mail calls for this sort of reason.
    – ceejayoz
    Jan 23, 2018 at 20:18
  • It's not my code, just trying to get it working, but down the road that might be a better option. I need to get it working with the original sfiab code to validate the setup. Also, allow kids to register for science fair. That sounds like a down the road improvement.
    – daemondave
    Jan 23, 2018 at 20:32

1 Answer 1


Have a look at third example of https://secure.php.net/manual/en/function.mail.php :

<?php mail('[email protected]', 'the subject', 'the message', null, '[email protected]');?>

The -f option is what you need to set the From value. A "@" alone is not good, maybe your settings in php.ini are not correct?

But also note that sendmail may decide to discard this value and put something else there, depending on its own settings, normally while putting a warning in logs.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .