I have a simple script setup:
<?php
mail('[email protected]', 'Hello World', 'Testing a message');
?>
I cannot send email from my server to AOL accounts. The error details are below. GMail lets me send the message...so I guess AOL is just a bit stricter.
Starting tcpick 0.2.1 at 2009-08-03 22:25 UTC
Timeout for connections is 600
tcpick: reading from tcp_dump.pcap
1 SYN-SENT 67.23.28.65:49516 > 64.12.138.153:smtp
1 SYN-RECEIVED 67.23.28.65:49516 > 64.12.138.153:smtp
1 ESTABLISHED 67.23.28.65:49516 > 64.12.138.153:smtp
220-rly-mg05.mx.aol.com ESMTP mail_relay_in-mg05.6; Mon, 03 Aug 2009 18:25:34 -0400
220-America Online (AOL) and its affiliated companies do not
220- authorize the use of its proprietary computers and computer
220- networks to accept, transmit, or distribute unsolicited bulk
220- e-mail sent from the internet. Effective immediately: AOL
220- may no longer accept connections from IP addresses which
220 have no reverse-DNS (PTR record) assigned.
EHLO bandop.com
250-rly-mg05.mx.aol.com fallsroadsunoco.com
250 HELP
MAIL FROM:<www-data@com>
501 SYNTAX ERROR IN PARAMETERS OR ARGUMENTS
RSET
250 OK
QUIT
1 FIN-WAIT-1 67.23.28.65:49516 > 64.12.138.153:smtp
2 SYN-SENT 67.23.28.65:45729 > 216.239.113.101:smtp
1 FIN-WAIT-2 67.23.28.65:49516 > 64.12.138.153:smtp
221 SERVICE CLOSING CHANNEL
1 RESET 67.23.28.65:49516 > 64.12.138.153:smtp
3 SYN-SENT 67.23.28.65:45729 > 216.239.113.101:smtp
tcpick: done reading from tcp_dump.pcap
20 packets captured
3 tcp sessions detected
Do you know how I can make the FROM parameter come out correctly? Setting the FROM header in the PHP mail function does not work.
UPDATE
This little hack is working but I would prefer to fix this issue outside of PHP.
mail('[email protected]', 'Hello World', 'Testing a message', null,'[email protected]');
I am super noob with mail servers
With AOL they often won't go through unless you fill out the form to get white listed. To change where the mail is coming from, edit the sendmail_path parameter in the php.ini file. This is mentioned in the php mail() doc under additional_parameters.
For Example:
You can also pass instead a parameter to the mail() function:
Lastly, you might find alternative mail package more flexible, such as PEAR MAIL package or msmtp, you can specify other smtp servers.
You want to change the envelope From: address, which is different from the From: header. See this comment in the mail() function's doc.
The envelope address depends on your MTAs configuration - in your case, 'www-data' is the user your script runs as, and 'com' is (part?) of your machine's hostname. Assuming you are on *nix, you can try to override the envelope address like this:
where [email protected] is the envelope sender address you want to show.
If that works, and you have access to your php.ini file, you can set the envelope sender address there - see Kyle's post.
You might also want to have a look at your MTAs (sendmail, postfix) configuration - looks like it has a problem with your hostname setting. Changing php-s settings will fix it for php, but if something else (cron, logwatch) on your system wants to sent mail, it would be helpful to have a working MTA.
Edit after your comment: It's hard to suggest anything without knowing your mail server's config, but for a start, try the following:
Try escaping the at sign.