在moodle 3.0上发送电子邮件时出现SMTP错误


SMTP error with sending Emails on moodle 3.0

在同一服务器上安装2个Moodle时,我有相同的电子邮件配置(在消息输出中):

  1. 2.9.1版+
  2. 3.0版

我正在使用Exchange服务器作为SMTP主机服务器。

在2.9上,电子邮件运行良好,但在3.0上,我有一个错误:

    250-SIZE 37748736
                                  250-PIPELINING
                                  250-DSN
                                  250-ENHANCEDSTATUSCODES
                                  250-STARTTLS
                                  250-X-ANONYMOUSTLS
                                  250-AUTH NTLM LOGIN
                                  250-X-EXPS GSSAPI NTLM
                                  250-8BITMIME
                                  250-BINARYMIME
                                  250-CHUNKING
                                  250 XRDST
 2015-12-22 09:47:25    CLIENT -> SERVER: STARTTLS
 2015-12-22 09:47:25    SMTP -> get_lines(): $data is ""
 2015-12-22 09:47:25    SMTP -> get_lines(): $str is  "220 2.0.0 SMTP server     ready                         
 2015-12-22 09:47:25    SERVER -> CLIENT: 220 2.0.0 SMTP server ready
 2015-12-22 09:47:26    SMTP Error: Could not connect to SMTP host.
 2015-12-22 09:47:26    CLIENT -> SERVER: QUIT
 2015-12-22 09:47:26    SMTP -> get_lines(): $data is ""
 2015-12-22 09:47:26    SMTP -> get_lines(): $str is  ""
 2015-12-22 09:47:26    SERVER -> CLIENT:
 2015-12-22 09:47:26    SMTP ERROR: QUIT command failed:
 2015-12-22 09:47:26    Connection: closed
 2015-12-22 09:47:26    SMTP connect() failed.     https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

请注意,我使用的配置完全相同,只是在2.9中您没有在(LOGIN、PLAIN、NTLM)之间进行选择,但它存在于3.0中,我已经尝试过所有配置。

有人知道发生了什么事吗?是bug还是我错过了什么,已经两天了,它变得令人沮丧。

虽然这是一个旧的讨论,但为了社区参考,MDL-52637中已经跟踪了该问题,并在v3.0.3中修复了该问题。
详细信息,请访问https://tracker.moodle.org/browse/MDL-52637.

HTH,
Matteo

如果您有Moodle SMTP传出邮件的问题,并且它不工作,您可以做几件事来检查它。

检查SMTP配置

在CCD_ 1处。

  1. 设置类似于noreplyaddresssmtpuser地址
  2. 确保连接端口跟在smtpsecure后面。例如,SSL端口是465,而smtphosts必须类似于mysmtp.server.com:465

使用内置Moodle工具测试电子邮件发送

/admin/testoutgoingmailconf.php

  1. /admin/settings.php?section=outgoingmailconfig0的当前用户(似乎是管理员)电子邮件更新为smtpuser
  2. 将调试模式设置为/admin/settings.php?section=debugging
  • debug作为开发者模式
  • debugdisplay-是
  1. 测试并查看结果

使用自己的PHP脚本手动测试(如果仍然不起作用)

<?php
require_once 'config.php';
$mail = get_mailer();
$mail->Sender = 'mysmtpaddress@site.com';//from your settings
$mail->Host = "smtp.host";//from your settings
$mail->Port = 465;//from your settings
$mail->isSMTP();
$mail->SMTPSecure = 'ssl';//from your settings
$mail->SMTPAuth = true;
$mail->setFrom("mysmtpaddress@site.com", "TEST");//from your settings
$mail->Username = "mysmtpaddress@site.com";//from your settings
$mail->Password = "MY_PASSWORD";//from your settings
$mail->AuthType = "Login";
$mail->isHTML(true);
$mail->Subject = "Email Subject Line";
$mail->Body = "This is a new text body.";
$mail->addAddress('yourmailtotestmoodlesmtp@site.com');//your receive email
$mail->SMTPDebug = 2;
$send = $mail->send();
echo print_r($send, 1);