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 = '[email protected]'; // 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('[email protected]'); // 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, "\r\n");
$body = $body . "\r\n" . "Phone: " .$_POST['phone'];
$mail->Subject = 'Contact Form';
$mail->Body = $body;
if(!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
}
else
{
echo 'success';
}
?>
$body = wordwrap($body, 70, "\r\n");
that will wrap your email body. kindly check with your mailhost provider and try with short html body – sas