问题
I want to send mail through PHP, so i am using PHPMailer. Don't know why i am getting this error.
Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: Relaying not allowed - sender domain not local SMTP code: 530
This is my code.
require '../library/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->IsSMTP();
//From email address and name
$mail->From = "my@email.address";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("my@email.address", "Recipient Name");
//$mail->addAddress("recepient1@example.com"); //Recipient name is optional
//Address to which recipient will reply
$mail->addReplyTo("p.archish@live.com", "Reply");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
//$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
Any help or suggestion? and i am not executing this code on local, it's on server.
回答1:
It's unusual for a server to allow sending without authentication. I suggest setting the Host, SMTPAuth, Username and Password properties, as the examples provided with PHPMailer show.
来源:https://stackoverflow.com/questions/37405077/mailer-error-smtp-error-data-not-accepted