Php 在XAMPP上发送电子邮件

Php 在XAMPP上发送电子邮件,php,email,xampp,sendmail.exe,Php,Email,Xampp,Sendmail.exe,首先,我想向你保证,我已经查过了。我整天都在做这件事,在这里和其他地方都读过多篇关于堆栈溢出的文章。我尝试了多种设置/配置,各种尝试和错误等。。。我意识到我一定是做错了什么/没有看到什么,但我似乎无法得到它 我正在Windows8.1机器上使用XAMPPV3.2.1(根据控制面板)。这仅用于开发/学习,因为XAMPP是有意使用的。我只是想让这个工作,以确保我的脚本运行良好。一切似乎都在工作,但我只是没有收到来自我的脚本的任何电子邮件,这只是一个简单的邮件脚本,用于测试和查看它是否工作- <

首先,我想向你保证,我已经查过了。我整天都在做这件事,在这里和其他地方都读过多篇关于堆栈溢出的文章。我尝试了多种设置/配置,各种尝试和错误等。。。我意识到我一定是做错了什么/没有看到什么,但我似乎无法得到它

我正在Windows8.1机器上使用XAMPPV3.2.1(根据控制面板)。这仅用于开发/学习,因为XAMPP是有意使用的。我只是想让这个工作,以确保我的脚本运行良好。一切似乎都在工作,但我只是没有收到来自我的脚本的任何电子邮件,这只是一个简单的邮件脚本,用于测试和查看它是否工作-

<?php

  mail("myid@yahoo.com", "Sample Mail", "Sample Content", "From:myid@gmail.com");

?>
这是我在sendmail.ini文件中的代码-

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP=gmail.com
smtp_port=587

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from=myid@gmail.com

; 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"`
[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=587

; 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=auto

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

default_domain=gmail.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

debug_logfile=debug.log

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

auth_username=myid@gmail.com
auth_password=mypassword

; if your smtp server uses pop3 before smtp authentication, modify the 
; following three lines.  do not enable unless it is required.

pop3_server=
pop3_username=
pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify 
; the "From: " header of the message content

force_sender=myid@gmail.com

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify 
; the "To: " header of the message content

force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting.  you can manually set the ehlo/helo name if required

hostname=gmail.com`

如果我遗漏了什么或需要任何其他信息,请让我知道,因为我很乐意提供。提前感谢您的帮助。

根据此答案():“您将需要一个额外的SMTP服务器应用程序,因为Xampp不支持它。”使用PHPMailer连接到您的gmail SMTP:(非常容易配置,工作非常好)好的,谢谢大家。我想这就是连接到ini文件的gmail SMTP部分所做的?不需要本地邮件服务器。不是吗?嗯,它不是配置中的东西,而是在我这边或Gmail那边的某个地方。后来我回来了,我的收件箱里有一封电子邮件,但它被延迟了,因为在收到时间戳之前,我已经有很长时间没有发送了。而且只有一封电子邮件,这意味着还有相当多的邮件没有送达。有没有人知道Gmail或我这边有什么问题,可能会延迟和/或阻止电子邮件的发送?嗯,我做了一个telnet测试,如果我通过587连接,那么它确实会连接到Gmail。那么,如果我正在连接Gmail,但它仍然没有被发送,那么可能是什么问题呢?