douzhu3367 2013-12-17 13:06
浏览 608

使用phpmailer发送电子邮件时出错 - 中继不允许的SMTP错误:数据不被接受

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';
}
?>
  • 写回答

2条回答 默认 最新

  • dsceme82487 2016-02-02 23:53
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图