-1

当我尝试通过 phpmailer 发送邮件时,出现了一些错误。像这样:

SMTP -> 从服务器:250-m1.mydomain.com
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
客户端 -> SMTP:STARTTLS
SMTP -> 从服务器:220 2.0.0 准备启动 TLS
客户端 -> SMTP:EHLO localhost.localdomain
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-AUTH PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
SMTP -> 错误:服务器不接受身份验证: 535 5.7.8 错误:身份验证失败:身份验证机制无效
CLIENT -> SMTP: RSET
SMTP -> FROM SERVER:250 2.0.0 Ok
CLIENT -> SMTP: MAIL FROM:
SMTP -> FROM SERVER:250 2.1.0 Ok
CLIENT -> SMTP: RCPT TO:
SMTP -> FROM SERVER:554 5.7.1 : Relay access denied
SMTP -> ERROR: RCPT not accepted from server: 554 5.7.1 : Relay access denied
CLIENT -> SMTP: quit
SMTP -> FROM SERVER:221 2.0.0 再见

我的php代码是这样的:

<?php
 require_once('class.phpmailer.php');
 $mail = new PHPMailer();
 $mail->IsSMTP();
 $mail->SMTPDebug = 3;
 $mail->SMTPSecure = "tls";
 $mail->SMTPAuth = true;
 $mail->Host = "m1.mydomain.com";
 $mail->Port = 25;
 $mail->Username = "service@mydomain.com";
 $mail->Password = "password";
 $mail->SetFrom('service@mydomain.com', 'service');
 $mail->Subject = "Fine Design - Avise me";
 $mail->Body = "This is very interest email for you";
 $mail->AddAddress("to@domain.com","name");
 if(!$mail->Send()) {
     $error = 'Mail error: '.$mail->ErrorInfo;
     echo "We're sorry, however, an error has occurred. You may manually e-mail us .";
     return false;
 } else {
     echo "Thanks! Your message was successfully sent.";
     return true;
 }
 ?>

但是我可以通过foxmail和其他客户端发送邮件,有人可以给我一些建议吗?

4

2 回答 2

0

您在端口 25 上使用 tls。这通常不应该工作,因为端口 25 通常用于没有 ssl/tls 的 smtp。

于 2013-11-21T10:42:30.053 回答
0

尝试使用端口 25 和端口 587 对其进行测试。添加:

$mail->SMTPOptions = array(
        'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
); 

我使用它并且在没有 SSL 的情况下工作正常。

于 2016-06-10T12:28:36.827 回答