问题描述
我正在尝试通过 XAMPP 配置 Sendmail 以发送电子邮件.在我的 sendmail.ini 中,我有以下设置:
I'm trying to configure Sendmail through XAMPP to send email. In my sendmail.ini I have these settings:
# Set default values for all following accounts.
logfile "C:xamppsendmailsendmail.log
account Gmail
tls on
port 587
tls_certcheck off
host smtp.gmail.com
from [email protected]
auth on
user [email protected]
password mypassword
account default : Gmail
我已经创建了一个这样的测试脚本:
I've created a test script like this:
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,
How are you?";
$headers = "From: [email protected]" . "
";
if (mail($to, $subject, $body, $headers)) {
echo ("Message successfully sent!");
} else {
echo ("Message delivery failed...");
}
我收到一条消息,说电子邮件已发送,但从未到达,并且在我收到的日志中:
I get a message to say that the email was sent but it never arrives and in the logs I get:
sendmail:传送过程中出错:必须先发出 STARTTLS 命令.
sendmail: Error during delivery: Must issue a STARTTLS command first.
有人知道这里可能有什么问题吗?
Does anybody know what the issue could be here?
提前致谢!
煤气
推荐答案
这对我有用 希望没有其他人会像我一样烧油来解决这个问题.
This is what worked for me Hopefully no one else will burn oil to figure this out like i did.
这是我的 sendmail.ini
Here is my sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=yourgmailpassword
[email protected]
php/php.ini ----基本上注释掉除了 sendmail_path & 之外的所有内容mail.add_x_header
php/php.ini ----basically comment everything out except sendmail_path & mail.add_x_header
[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:xamppsendmailsendmail.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:xamppapachelogsphp_mail.log"
这在我更新了 sendmail 文件后对我有用(旧的不支持 smtp)
This worked for me after i updated the sendmail files (the old ones dont support smtp)
- 前往http://glob.com.au/sendmail/ 获取最新的sendmail压缩文件
- 解压缩到桌面并将文件复制到您的 xamppsendmail 文件夹中,替换那里的所有内容.一切!
- 现在打开 sendmail.ini 并复制粘贴我上面显示的内容.(首先删除该文件中的所有内容或将所有内容都注释掉!)
- 注意:您不需要为此启动 Mercury 服务器.
- go to http://glob.com.au/sendmail/ and grab the latest sendmail zip file
- unzip to desktop and copy the files into your xamppsendmail folder replacing everything that was there.EVERYTHING!
- Now open up sendmail.ini and copy paste what i showed above.(remove everything in that file first or just comment everything out!)
- NOTE: you dont need Mercury servers started for this.
当我遇到这个问题时,我正在本地主机上进行密码恢复 php.我需要向用户发送他们的密码.- 你的 php 看起来不错
I was making a password recovery php on localhost when i encountered this problem. I needed to send users their password.- your php looks okey
这篇关于使用 Gmail 帐户的 XAMPP Sendmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!