为什么 php 邮件功能在 xampp 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16890226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
why php mail function not work in xampp
提问by Good Boy
I have problem i use xampp . i want check mail form but i can't see any result . i config Mercury/32 like this tutorial in this site :
我有问题,我使用 xampp 。我想检查邮件表格,但我看不到任何结果。我在本网站中像本教程一样配置 Mercury/32:
http://system66.blogspot.com/2010/01/how-to-send-mail-from-localhost-with.html
http://system66.blogspot.com/2010/01/how-to-send-mail-from-localhost-with.html
i check email by outlook it's work . i check send mail by Mercury send mail in admin panel and it's correctly work .
我通过 Outlook 检查电子邮件它的工作。我在管理面板中检查了 Mercury 发送邮件的发送邮件,它正常工作。
but i can't send email and can not recive this email by outlook when i use mail php function .
但是当我使用邮件 php 功能时,我无法发送电子邮件,也无法通过 Outlook 收到这封电子邮件。
why ?
为什么 ?
please help me
请帮我
回答by Good Boy
I got it . i set this config and now i can recieve my sent email in outlook:
我知道了 。我设置了这个配置,现在我可以在 Outlook 中收到我发送的电子邮件:
I just need to configure
D:\xampp\sendmail\sendmail.ini
By default, it contains the line
我只需要配置
D:\xampp\sendmail\sendmail.ini
默认情况下,它包含行
smtp_server=mail.mydomain.com
I had to change it to
我不得不把它改成
smtp_server=localhost
No need to configure this in the older versions of XAMPP.
The correct configuration for [mail function] in
D:\xampp\php\php.ini
is
无需在旧版本的 XAMPP 中进行配置。[邮件功能]中的正确配置
D:\xampp\php\php.ini
是
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = 127.0.0.1 smtp_port = 25
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\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 = "\"D:\xampp\sendmail\sendmail.exe\" -t"
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the D:\xampp\mailoutput folder
; sendmail_path ="D:\xampp\mailtodisk\mailtodisk.exe"
; XAMPP:如果你想使用像 Mercury 这样的 SMTP 服务器,请注释掉这个
SMTP = 127.0.0.1 smtp_port = 25
; XAMPP 重要说明 (1):如果 XAMPP 安装在带有空格的基本目录(例如 c:\program filesD:\xampp)中,fakemail 和 mailtodisk 将无法正常工作。; XAMPP 重要说明 (2):在这种情况下,请复制根文件夹中的 sendmail 或 mailtodisk 文件夹(例如 C:\sendmail)并将其用于 sendmail_path。
; XAMPP:如果您想使用 fakemail 转发到您的邮箱(sendmail 文件夹中的 sendmail.exe),请注释掉这个
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
; XAMPP:如果您想使用 mailToDisk,请注释掉它,它将所有邮件写入 D:\xampp\mailoutput 文件夹
; sendmail_path ="D:\xampp\mailtodisk\mailtodisk.exe"
Now, I'm receiving mails in my inbox. Please note that "D:\xampp\" is my XAMPP installation path.
现在,我正在收件箱中接收邮件。请注意“D:\xampp\”是我的 XAMPP 安装路径。
Thanks to all friends
感谢所有的朋友
回答by Bruce
For this you need to call your ISP and ask them for the smtp out server address. Once done, You need to configure you SMTP settings in C:xampp\php\php.ini file or you can add the following line at the beginning of your php script.
为此,您需要致电您的 ISP 并向他们询问 smtp 输出服务器地址。完成后,您需要在 C:xampp\php\php.ini 文件中配置 SMTP 设置,或者您可以在 php 脚本的开头添加以下行。
ini_set("SMTP","yoursmtpoutgoingserver");
ini_set("SMTP","yoursmtpoutgoingserver");
回答by user2444875
You have to set your SMTP server settings in the php.ini file
您必须在 php.ini 文件中设置您的 SMTP 服务器设置
[mail function]
; For Win32 only.
; "http://php.net/smtp"
SMTP = localhost
; "http://php.net/smtp-port"
smtp_port = 25
if you don't run a mailserver locally, you will need to access a remote one like your isp or gmail
如果您不在本地运行邮件服务器,则需要访问远程服务器,例如您的 isp 或 gmail
[mail function]
; For Win32 only.
SMTP = mail.yourserver.com
smtp_port = 25
auth_username = smtp-username
auth_password = smtp-password
sendmail_from = [email protected]
回答by Zohaib
This works for me, hope it will help you:
这对我有用,希望它能帮助你:
- Edit your php.ini (xampp\php\php.ini). Search for [mail function] and change these parameters accordingly.
- SMTP = smtp.gmail.com
- smtp_port = 587
- sendmail_from = [your_gmail_username]@gmail.com Note: this gmail account will be used to send the email
- sendmail_path = “\”D:\xampp\sendmail\sendmail.exe\” -t” Note: I did install my xampp at D:\xampp
- Edit your sendmail.ini (xampp\sendmail\sendmail.ini)
- 编辑你的 php.ini (xampp\php\php.ini)。搜索 [mail function] 并相应地更改这些参数。
- SMTP = smtp.gmail.com
- smtp_port = 587
- sendmail_from = [your_gmail_username]@gmail.com 注意:此 gmail 帐户将用于发送电子邮件
- sendmail_path = “\”D:\xampp\sendmail\sendmail.exe\” -t” 注意:我确实在 D:\xampp 安装了我的 xampp
- 编辑你的 sendmail.ini (xampp\sendmail\sendmail.ini)
Comment the “Mercury” and “A free mail service example” contents as shown below:
# Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off
# A freemail service
#account Hotmail
#tls on
#tls_certcheck off
#host smtp.live.com
#from [exampleuser]@hotmail.com
#auth on
#user [exampleuser]@hotmail.com
#password [examplepassword]
注释“Mercury”和“免费邮件服务示例”内容,如下所示:
# Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off
#免费邮件服务
#account Hotmail
#tls on
#tls_certcheck off
#host smtp .live.com
#from [exampleuser]@hotmail.com
#auth on
#user [exampleuser]@hotmail.com
#password [examplepassword]
- Add the account through which you want to send your mails. In my example I have configured the Gmail account as shown below:
- account Gmail
- tls on
- tls_certcheck off
- host smtp.gmail.com
- from [your_gmail_username]@gmail.com
- auth on
- user [your_gmail_username]@gmail.com
- password [your_gmail_password]
port 587
- Set the default account to Gmail as shown below:
account default : Gmail
- 添加您要通过其发送邮件的帐户。在我的示例中,我配置了 Gmail 帐户,如下所示:
- 帐户 Gmail
- 开启
- tls_certcheck off
- 主机 smtp.gmail.com
- 来自 [your_gmail_username]@gmail.com
- 授权
- 用户 [your_gmail_username]@gmail.com
- 密码 [your_gmail_password]
587端口
- 将默认帐户设置为 Gmail,如下所示:
帐户默认:Gmail