我可以通过我的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 = 25php_openssl.dll已启用
请给我一些直接的指导,因为我在无数的试验中浪费了太多的时间,但都没有成功。
发布于 2013-12-01 12:37:03
尝试127.0.0.1而不是localhost
发布于 2021-04-28 03:57:02
您的php邮件文件是正确的,但您必须使用当前主机。您可以在sendgrid上获取一个免费的SMTP帐户进行测试,您可以使用此SMTP帐户。
https://stackoverflow.com/questions/20308704
复制相似问题