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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?