【发布时间】:2019-10-22 06:15:33
【问题描述】:
我正在使用 wampp 服务器,并尝试使用 php 脚本发送邮件。但我遇到了错误。
我用不同的方式配置了php.ini文件,wamp服务器没有sendmail文件。
那么如何设置呢?
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from =myMail1@gmail.com
<?php
$from = "myMail1@gmail.com";
$to = "test_one@outlook.com";
$subject = "Checking PHP mail";
$message = "PHP mail works just fine";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
?>
警告:mail():无法连接到邮件服务器 “localhost”端口 25,验证您的“SMTP”和 php.ini 中的“smtp_port”设置或使用 ini_set() C:\wamp64\www\sendMail\index.php 在第 9 行
我想消除这个错误。我重启了我的服务器几次。
【问题讨论】:
-
您需要一个 SMTP 服务器来发送您的电子邮件,如果您使用的是 gmail,您的服务器将是 smtp.gmail.com,而您的端口将是 465 (SSL) 或 587 (TLS)。据我记得,您还需要在您的 gmail 帐户中设置一些配置,以便允许通过 SMTP 发送电子邮件。
-
您使用哪个操作系统?以下是有关在 Linux 上设置 sendmail 的文档:docs.bitnami.com/installer/infrastructure/wamp/troubleshooting/…
-
为了在Windows上开发,我使用了这个工具:toolheap.com/test-mail-server-tool它将消息存储在指定的文件夹中而不是实际发送它们
标签: php wamp sendmail wampserver