Reputation: 2628
I have the following code to send an email.
<?php
$NowDate = date('Y-m-d H:i:s');
$subject = "test subject";
$message ="test message";
$emailFrom = "[email protected]";
$EmailAddress = "[email protected]";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: My Site <".$emailFrom.">\r\n";
$headers .= "To: <".$EmailAddress.">\r\n";
mail($EmailAddress,$subject,$message,$headers);
?>
It runs successfully but the email doesn't getting sent with the following error listed in CPanel.
How do I go about resolving this?
ECDHE-RSA-AES256-GCM-SHA384:256 CV=no: SMTP error from remote mail server after end of data: 550 Messages should have one or no To headers, not 2.
Upvotes: 2
Views: 35
Reputation: 5224
You need to remove the To
header. The first parameter of the mail
function writes that header value. With it assigned in the header as well you send 2 to
s which causes the error.
So remove:
$headers .= "To: <".$EmailAddress.">\r\n";
Upvotes: 1