问题描述
我正在尝试通过XAMPP配置Sendmail来发送电子邮件。在我的sendmail.ini我有这些设置:
#设置所有以下帐户的默认值。
logfileC:\xampp\sendmail\sendmail.log
帐户Gmail
tls
端口587
tls_certcheck off
host smtp.gmail.com
from [email protected]
auth on
用户[email protected]
密码mypassword
帐号默认值: Gmail
我创建了一个这样的测试脚本:
$ to [email protected];
$ subject =嗨!;
$ body =\\\
你呢?;
$ headers =From:[email protected]。\r\\\
;
if(mail($ to,$ subject,$ body ,$ headers)){
echo(Message successfully sent!);
} else {
echo(Message delivery failed ...);
}
我收到一条消息,说电子邮件已发送,但从来没有到达,我收到的日志中: / p>
sendmail:发货时出错:首先必须发出STARTTLS命令。
有人知道问题可能是什么在这里?
提前感谢
Gaz
这是对我有用的希望没有人会燃烧油,像我这样做。
这是我的sendmail.ini
[sendmail]
smtp_server = smtp.gmail.com
smtp_port = 25
error_logfile = error.log
debug_logfile = debug.log
auth_username [email protected]
auth_password = yourgmailpassword
[email protected]
php / php.ini ----基本上将所有内容都注释掉,除了sendmail_path& mail.add_x_header
[邮件功能]
;仅适用于Win32
; http://php.net/smtp
; SMTP = localhost
; http://php.net/smtp-port
; smtp_port = 25
;仅适用于Win32
; http://php.net/sendmail-from
; sendmail_from = postmaster @ localhost
;仅适用于Unix您也可以提供参数(默认值:sendmail -t -i)。
; http://php.net/sendmail-path
sendmail_path =\C:\xampp\sendmail\sendmail.exe\-t
;强制添加要作为额外参数
传递的指定参数;到sendmail二进制文件。这些参数将始终代替
的值; mail()的第五个参数,即使在安全模式下。
; mail.force_extra_parameters =
;添加X-PHP起始脚本:这将包括脚本后面的文件名
mail.add_x_header = Off
;记录所有mail()调用,包括脚本的完整路径,行#,到地址和标题
; mail.log =C:\xampp\apache\logs\php_mail.log
在我更新sendmail文件(旧的不支持smtp)之后,这对我有用b
$ b
- 转到,并获取最新的sendmail zip文件
- 解压缩到桌面并将文件复制到您的\xampp\sendmail文件夹中,替换所有内容.EVERYTHING !
- 现在打开sendmail.ini并复制粘贴我上面显示的内容(先删除该文件中的所有内容,或者将所有内容全部删除!)
- 注意:您不需要为此启动Mercury服务器。
当我遇到此问题时,我正在本地主机上进行密码恢复php。我需要向用户发送他们的密码。
- 你的php看起来okey
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:\xampp\sendmail\sendmail.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,\n\nHow are you?";
$headers = "From: [email protected]" . "\r\n";
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: Error during delivery: Must issue a STARTTLS command first.
Does anybody know what the issue could be here?
Thanks in advance!
Gaz
This is what worked for me Hopefully no one else will burn oil to figure this out like i did.
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 ----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:\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"
This worked for me after i updated the sendmail files (the old ones dont support smtp)
- go to http://glob.com.au/sendmail/ and grab the latest sendmail zip file
- unzip to desktop and copy the files into your \xampp\sendmail 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.
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
这篇关于XAMPP Sendmail使用Gmail帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!