我正在尝试通过XAMPP配置Sendmail来发送电子邮件。在我的sendmail.ini中,我有以下设置:
# Set default values for all following accounts.
logfile "C:\xampp\sendmail\sendmail.log
account Gmail
tls on
port 587
tls_certcheck off
host smtp.gmail.com
from myemail@gmail.com
auth on
user myemail06@gmail.com
password mypassword
account default : Gmail
我已经创建了一个测试脚本,如下所示:
$to = "testemail@btinternet.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$headers = "From: myemail06@gmail.com" . "\r\n";
if (mail($to, $subject, $body, $headers)) {
echo ("Message successfully sent!");
} else {
echo ("Message delivery failed...");
}
我收到一条消息,说电子邮件已发送,但它从未到达,并且在日志中我收到:
sendmail:传送过程中出错:必须先发出STARTTLS命令。
有人知道这里的问题是什么吗?
提前感谢!
Gaz
发布于 2011-03-21 13:50:49
这就是对我有效的方法,希望其他人不会像我一样烧油来解决这个问题。
这是我的sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=myemail@gmail.com
auth_password=yourgmailpassword
force_sender=myemail@gmail.com
php/php.ini -基本上注释掉除sendmail之外的所有内容_路径和mail.add_X_标题
[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 = postmaster@localhost
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off
; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"
在我更新了sendmail文件(旧的不支持smtp)后,这对我起作用了。
当我遇到这个问题时,我正在本地主机上做一个密码恢复php。我需要向用户发送他们的密码。-你的php看起来没问题
发布于 2012-06-14 01:35:13
好吧,今天,最好的答案对我不起作用。但是,这确实做到了:
在sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=****@gmail.com
auth_password=*******
force_sender=****@gmail.com
在php.ini:
[mail function]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
基于端口@:http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
发布于 2015-07-25 04:43:21
我所要做的就是将“允许不太安全的应用程序访问你的帐户”切换到on。我猜这是创建应用程序特定密码的另一种选择。
https://support.google.com/accounts/answer/6010255获取信息
https://www.google.com/settings/security/lesssecureapps对于交换机
出于安全考虑,可能值得在完成后将其关闭。
https://stackoverflow.com/questions/4948687
复制相似问题