【发布时间】:2021-04-28 03:57:01
【问题描述】:
我在通过我的 PHP 站点发送电子邮件时遇到了麻烦。我使用下面的代码(尝试了我可以用谷歌搜索的所有内容,但这对我来说最有意义 - 仍然无法正常工作)
$mail = new PHPMailer();
$mail->From = "me@localhost";
$mail->FromName = "My Name";
$mail->AddAddress("someExistingAddress@gmail.com");
$mail->Subject = "Test PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->Subject = "PHPMailer Test Subject via smtp";
$mail->Host = "localhost"; // SMTP server
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = false;
$mail->Port = 25;
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
执行原因:“SMTP 错误:无法连接到 SMTP 主机”。
我在 Windows 7 上的 IIS (7.5) 上安装了 SMTP,这是我的设置(翻译自波兰语):
SMTP:
地址电子邮件:
me@localhost(那个字段是什么?它甚至不检查正确性,我可以在没有@的情况下输入)
向服务器 SMTP 发送电子邮件:
本地主机
港口:
25
并且不需要身份验证。
Php.ini:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
php_openssl.dll 已启用
请给我一些直接的指导,因为我在无数次试验上浪费了太多时间,但没有成功。
【问题讨论】: