RE: [PHP] Unable to send mail from PHP to AT&T e-mail address
| From: | kyle.smith | Date: | Wed, 22 Apr 2009 18:05:58 +0000 |
| Subject: | RE: [PHP] Unable to send mail from PHP to AT&T e-mail address | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-291825@lists.php.net to get a copy of this message | ||
> Phpster wrote:
>>
>>
>> On Apr 21, 2009, at 20:32, Edward Diener <eldml@tropicsoft.com>
wrote:
>>
>>> I have a PHP script which uses the PHP 'mail' function. When the
>>> script's 'to' address is an AT&T address, such as my own as an
>>> AT&T
>>> ISP customer, the mail never gets to me. If the 'to' address is
>>> anything other than an AT&T address, the mail gets to the recipient.
>>> The PHP code for sending the mail is essentially:
>>>
>>> $headers = 'MIME-Version: 1.0' . "\r\n";
>>> $headers .= 'Content-type: text/html; charset=iso-8859-1' .
"\r\n";
>>> $headers .= 'From: Some From Name <somefromname.com>';
>>> $to = 'mybellsouthaddress.net';
>>> $subject = 'Some Subject';
>>> $msg = 'Some Message';
>>> if(mail($to,$subject,$msg."\r\n\r\n",$headers))
>>> echo "good";
>>> else
>>> echo "bad";
>>>
>>> In the actual PHP script the $to, $subject, and $msg are
>>> successfully passed to the script from the client side as $_POST,
>>> $_POST and $_FILES parameters respectively. I have just filled them
>>> in above so that they can be seen as if they were part of the
>>> script. The script always returns "good", so the mail function must
be successful.
>>>
>>> In my project, testing has reported that any attempt to use the
>>> 'mail' function on the server to send to an AT&T address fails to
>>> reach the recipient, while all other addresses used in the testing
>>> succeed in reaching the recipient. I can assert this to be the case
>>> with my own AT&T address also. I have also checked my AT&T mailbox
>>> online to make sure the mail is not being received as Spam.
>>>
>>> Does anybody have an idea why using the 'mail' function succeeds
>>> with all but AT&T $to addresses ? Naturally in the client-server
>>> application on which I am working, sending mail from the server must
>>> work for all $to addresses.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/) To unsubscribe,
>>> visit: http://www.php.net/unsub.php
>>>
>>
>> It might be that the server IP has been blacklisted with at&t as a
>> domain from which spam is sent.
>
> I have found out that the server adds a from header of
> 'nobody@myserver.com' where 'myserver' is the name of the server. This
> header gets placed first before the From header I supply in my PHP
> script ( which should have had the form in the example above of
> 'somefromname@myserver.com, my bad ).
>
> Perhaps the AT&T mail server, when it sees the 'nobody@myserver.com'
> treats it as spam and does not deliver the mail to even the
> recipient's spam mailbox.
>
> I am not sure if it is normal for outgoing SMTP mail servers to
> automatically add the 'nobody@myserver.com' from address first in the
> header, or even why it does so ? Does anybody know if this is normal
> for mail servers to do this ? Evidently other incoming mail servers do
> not react to the 'nobody@myserver.com' in any way, so maybe AT&T is
> unique in this.
>
> Any light anyone can throw on the 'nobody@myserver.com' address would
> be most welcome.
>It is using the apache user @ your host name as the default. Try this:
>ini_set('sendmail_from', 'whatever@wherever.com');
You can also add headers to display custom formatted From: with a nice
display name, like this:
$to = "joe@user.com";
$subject = "Automated Notification";
$body = "Joe, you're using too much disk space!"; $headers = "From:
Automated Disk Notifications <no-reply@website.com>\n\rReply-to:
no-reply@website.com\n\r";
mail($to, $subject, $body, $headers);
EDIT: Oops, didn't read OP. Sorry!