I am trying to send email using phpmailer, but the following code fails to send email with this error:
SMTP ERROR: DATA END command failed: 553 Relaying disallowed SMTP Error: data not accepted. Mailer Error: SMTP Error: data not accepted.
Code is below:
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->CharSet = 'UTF-8';
// Set mailer to use SMTP
$mail->Host = 'smtp.zoho.com'; // Specify main and backup server
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'noreply@website.com'; // SMTP username
$mail->Password = '846Support.x.1'; // SMTP password
$mail->SMTPSecure = 'ssl';
$mail->Port = 465; // Enable encryption, 'ssl' also accepted
$mail->From = $_POST['email'];
$mail->FromName = $_POST['name'];
$mail->addAddress('info@website.com'); // Add a recipient
$mail->addReplyTo($_POST['email'], $_POST['name']);
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$body = $_POST['message'];
$body = wordwrap($body, 70, "
");
$body = $body . "
" . "Phone: " .$_POST['phone'];
$mail->Subject = 'Contact Form';
$mail->Body = $body;
if(!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
}
else
{
echo 'success';
}
?>
I guess Zoho SMTP server doesn't accept sending mail with from e-mail diferent of smtp login mail.. I changed and it has passed imediatelly.
-You can still use Zoho with little change. - The problem: relay is disallowed because the From address (which user entered) and Sender (which you specified to be admin email) address are not matched. You can visit wp-admin/Tools/Email Log to verify. -Work around: change From address with Sender address, you still know who is sending this email, look at Return Part. - Hands on: go to /wp-content/plugins/postman-smtp/Postman/Postman-Mail/PostmanZendMailEngine.php, go to near end of this file and comment this line: $senderEmail = $sender->getEmail (); then the address with Send value, see below for final result // $senderEmail = $sender->getEmail (); $senderEmail = $this->transport->getFromEmailAddress (); - It should work now.