首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用Gmail帐户的XAMPP Sendmail

使用Gmail帐户的XAMPP Sendmail
EN

Stack Overflow用户
提问于 2011-02-10 02:05:16
回答 11查看 98.4K关注 0票数 19

我正在尝试通过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

EN

回答 11

Stack Overflow用户

发布于 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)后,这对我起作用了。

  • 转到http://glob.com.au/sendmail/并获取最新的sendmail zip文件
  • 解压到桌面并将文件复制到您的\xampp\sendmail文件夹中,替换there.EVERYTHING中的所有内容!
  • 现在打开sendmail.ini并复制粘贴我上面显示的内容。(首先删除该文件中的所有内容,或者注释掉所有内容!)
  • 注意:您不需要为此启动Mercury服务器。

当我遇到这个问题时,我正在本地主机上做一个密码恢复php。我需要向用户发送他们的密码。-你的php看起来没问题

票数 36
EN

Stack Overflow用户

发布于 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

票数 13
EN

Stack Overflow用户

发布于 2015-07-25 04:43:21

我所要做的就是将“允许不太安全的应用程序访问你的帐户”切换到on。我猜这是创建应用程序特定密码的另一种选择。

https://support.google.com/accounts/answer/6010255获取信息

https://www.google.com/settings/security/lesssecureapps对于交换机

出于安全考虑,可能值得在完成后将其关闭。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4948687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档