I get a Pear message of, “Validation failed for: My-Example.com" when $from = "My-Example.com <support@my-example.com>”. However, I don’t get an error if I change $from to "Example <support@my-example.com>" Why would having a hypen and a .com as part of the FROM address cause validation errors?
Also, is this the most efficient way to send out 500 emails or more at one time? I don’t know tons about SMTP, but I assume it is authenticating with the SMTP server for every single email that is being sent out with my DO WHILE loop.
Thoughts?
$from = "My-Example.com <support@my-example.com>";
$host = "mail.my-example.com";
$username = "support@my-example.com";
$password = "******";
$headers = array (
'To' => $recipient,
'From' => $from,
'Subject' => $subject,
'Reply-To' => $sender,
'Errors-To' => $sender);
$smtp = Mail::factory('smtp', array (
'host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($recipient, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
$success = "Yes";
//Code for updating the DB table so the email doesn't get resent.
}