Reputation: 3716
hi i get this error when i try to send email
SMTP -> ERROR: MAIL not accepted from server: 501 : sender address must contain a domain
it used to work fine i'm not sure what happend i use php mailer but i dont think this is important
$smtp = setting::get_smtp( 1 , 'support');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = $smtp->address; //localhost
$mail->CharSet = "utf-8";
$mail->SMTPAuth = true;
$mail->Port = $smtp->port; // 25
$mail->Username = $smtp->username;
$mail->Password = $smtp->password;
$mail->From = $smtp->from ; // www.mysite.com
$mail->AddReplyTo ($smtp->username , $smtp->from ); // [email protected] //www.mysite.com
$mail->Subject = $title;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($msg);
$mail->SMTPDebug = 1;
if( filter_var( $admin_email , FILTER_VALIDATE_EMAIL ) == TRUE ){
$mail->AddAddress($admin_email , "John Doe");
$mail->Send();
}
Upvotes: 2
Views: 16447
Reputation: 270609
The error message is a bit misleading, but the problem is clear. The From:
header must contain a domain as a complete email address. If your $smtp->from
contains www.mysite.com
, that is an invalid email address, missing the part after @
. The mailer misinterprets your domain name as only the first part of an email address (the user part) and complains that it needs @domain
to go with it. Supply a full sender email address to your $smtp->from
property.
// Should be something like [email protected]
$mail->From = $smtp->from ;
Upvotes: 5