PHP Sendmail在windows xampp中失败

PHP Sendmail在windows xampp中失败,php,xampp,sendmail,sendmail.exe,Php,Xampp,Sendmail,Sendmail.exe,我正在尝试通过我的gmail帐户在windows中发送邮件,我已经配置了我的php.ini: SMTP=smtp.gmail.com smtp_port=587 sendmail_from=jaisanas2@gmail.com sendmail_path="\"C:\xampp\sendmail\sendmail.exe\" -t" and sendmail.ini : smtp_server=smtp.gmail.com smtp_port=587

我正在尝试通过我的gmail帐户在windows中发送邮件,我已经配置了我的php.ini:

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from=jaisanas2@gmail.com
sendmail_path="\"C:\xampp\sendmail\sendmail.exe\" -t"

and sendmail.ini :
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=confidential@gmail.com
auth_password=my-password-confident
force_sender=confidential@gmail.com
这是我的密码:

<?php
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");

// Send
$send = mail('jaisanas2@gmail.com', 'My Subject', $message);
if ($send) {
    echo "send";
}
else {
echo "fail";}
?>

我也改变了我的谷歌安全变得不那么安全
我不知道为什么,有人帮我吗?

我不确定你是否在使用Windows 8,但如果你在使用,你必须执行以下操作-

1)在PHP.ini中,使电子邮件部分如下所示

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = 

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

; 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=on
2)使sendmail.ini smtp部分如下所示

smtp_server=localhost

; smtp port (normally 25)

smtp_port=25

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

smtp_ssl=none

; if your smtp server requires authentication, modify the following two lines

auth_username=user@gmail.com
auth_password=password
3)下载Stunnel并在Stunnel.conf中进行以下更改。Stunnel正在托盘中运行,每次进行更改时,右键单击Stunnel图标并重新加载conf文件

cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
key = stunnel.pem
[ssmtp]
accept  = 465
connect = 25
[gmail-smtp]
client = yes
accept = 127.0.0.1:25
connect = smtp.gmail.com:465
; To check logs you can enable logging using following lines
debug = 7
4)转到Sendmail文件夹,单击Sendmail.exe->属性->兼容性->单击“为所有用户进行更改”按钮->选择Windows XP(Service Pack 3)兼容性并勾选“以管理员身份运行”

5)始终以管理员身份启动XAMPP

这只在Windows 8+上需要(例如,在Windows 2008 R2上,我只需要正确地将sendmail发送到gmail,一切正常)。

发送到Windows 8

更换后

1-php.ini

2-sendmail.ini

转到C:\xampp\sendmail

  • 1) 右键单击sendmail.exe并转到属性
  • 2) 单击兼容性选项卡,然后单击更改所有用户的设置
  • 3) 将兼容模式设置为Windows XP(Service Pack 3)
  • 4) 单击以管理员身份运行此程序的复选框
希望这能帮助别人


它对我的

起作用,你不能逃避
sendmail\u路径中的反斜杠
。这看起来不对。它仍然失败,我已将它更改为sendmail\u path=“\”C:\\xampp\\sendmail\\sendmail.exe \“-t”我不知道本地服务器是否可以与联机服务器交互。mei的新功能不知道Jean Gkol,但它似乎对某些人有用大多数时候你无法从本地服务器发送邮件,你需要将文件上载到实时服务器。选择Windows XP(Service Pack 3)是所有sendmail问题的正确答案!!祝贺