【发布时间】:2014-08-22 06:13:31
【问题描述】:
我实际上是使用 sendmail 的新手,但我已经阅读了很多关于此的内容,并且只将我重定向到使用 PHPmailer、swiftmailer 等……但是如果没有基础知识,理解起来非常复杂。所以我决定尝试简单,这就是我所拥有的。
我已经配置了我的 php.ini:
[mail function]
smtp_port = 465
sendmail_path="C:\wamp\sendmail\sendmail.exe -t"
mail.add_x_header = On
还有我的 sendmail.ini:
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
auth_username=mygmail@gmail.com
auth_password=mypassword
hostname=localhost
我有这个 PHP 代码:
$to = 'mygmail@gmail.com';
$message = $_POST['message'];
$email = $_POST['email'];
$contact_num = $_POST['contact_number'];
$headers = 'From:'.'$email' . "\r\n" .'$contact' . "\r\n" .
'Reply-To: mygmail@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $message, $headers);
但是,当我单击提交按钮时,sendmail.exe 会出现,但没有任何反应。当我检查 error.log 时,它说:
14/07/01 23:23:48 : Connection Closed Gracefully.
【问题讨论】:
-
您使用的是什么服务器?你如何运行你的服务器?
-
您找到解决方案了吗?我以管理员身份打开 XAMPP,之后 sendmail.exe 没有打开,邮件功能返回 true,但 gmail 帐户没有收到邮件
标签: php gmail sendmail.exe