Edward Diener 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.

Try using SMTP as your mail server. Increasingly, incoming mail servers are requiring secure email. This means logging into your outgoing server. Also, I've starting using Domain Keys and SPF on all my emails, including text to cellphones.

Here is my code function, it works with AT&T just fine. Note the use of Pear 
mail

function pearEmailSend($recipient, $emailSubj, $emailText, $applicEmailAddr)
{
    $emailTo = $recipient;
    $headers['From'] = $applicEmailAddr;
    $headers['To'] = $emailTo;
    if(!empty($emailCC)) $headers['Cc'] = $emailCC;
$headers['Return-Path'] = $applicEmailAddr; //or can use SMTP_USER; bounces are sent to applic address
    $headers['Reply-To'] = $applicEmailAddr;
    $headers['X-miniReg'] = APPLIC_NAME;
    $headers['Date'] = date('r');
    $headers['Subject'] = $emailSubj;
    $params['debug'] = SMTP_DEBUG; //Careful, do not leave on, creates a nasty 
message for admins
    $params['host'] = $_SERVER['SERVER_NAME'];
    $params['auth'] = SMTP_AUTH; //binary, set in config; some servers require 
auth
    $params["username"] = SMTP_USER; //If auth true, must have value
    $params["password"] = SMTP_PW; //If auth true, must have value
    $params["localhost"] = $_SERVER['SERVER_NAME'];
    $params['persist'] = true; //Default true
    $mail_object = &Mail::factory('smtp', $params);
    if(!ENABLE_SEND)
    {
echo("<br />pearEmailSend; sending is inhibited. This is the stuff. <br />Recipient=>$recipient<br />Text=>$emailText");
        echo printArray($headers) . '<br />';
        return;
    }
    $result = $mail_object->send($recipient, $headers, $emailText);
    if (PEAR::isError($result))
    {
throw new Exception("The email SMTP login does not work, check the config settings. <br />Tech support required. Error found in pearEmailSend()" . $result->getMessage());
    }
    return true;
}





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to