php 配置 WAMP 服务器以发送电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5773288/
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
Configure WAMP server to send email
提问by user544079
Is there a way that I can configure the WAMP serverfor PHP to enable the mail()
function?
有没有办法可以为 PHP配置WAMP 服务器以启用该mail()
功能?
回答by Wesley Murch
Configuring a working email client from localhost is quite a chore, I have spent hours of frustration attempting it. I'm sure someone more experienced may be able to help, or they may perhaps agree with me.
从本地主机配置一个工作的电子邮件客户端是一件很麻烦的事,我花了几个小时的挫折尝试。我相信更有经验的人可能会提供帮助,或者他们可能同意我的看法。
If you just want to test, here is a great tool for testing mail locally, that requires almost no configuration:
如果你只是想测试,这里有一个很好的本地测试邮件的工具,几乎不需要配置:
http://www.toolheap.com/test-mail-server-tool/
http://www.toolheap.com/test-mail-server-tool/
It worked right off the bat for me, hope this helps you.
它对我来说立竿见影,希望这对你有帮助。
回答by gianjey
Install Fake Sendmail(download sendmail.zip). Then configure C:\wamp\sendmail\sendmail.ini:
安装Fake Sendmail(下载sendmail.zip)。然后配置C:\wamp\sendmail\sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=465
[email protected]
auth_password=your_password
The above will work against a Gmail account. And then configure php.ini:
以上将适用于 Gmail 帐户。然后配置php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Now, restart Apache, and that is basically all you need to do.
现在,重新启动 Apache,这基本上就是您需要做的全部工作。
回答by David Hobs
Using an open source program call Send Mail, you can send via wamp rather easily actually. I'm still setting it up, but here's a great tutorial by jo jordan. Takes less than 2 mins to setup.
Just tried it and it worked like a charm! Once I uncommented the error log and found out that it was stalling on the pop3 authentication, I just removed that and it sent nicely. Best of luck!
使用开源程序调用Send Mail,您实际上可以很容易地通过 wamp 发送。我仍在设置它,但这是 jo jordan的精彩教程。设置时间不到 2 分钟。
刚试过,它就像一个魅力!一旦我取消了错误日志的注释并发现它在 pop3 身份验证中停滞不前,我就删除了它并且它发送得很好。祝你好运!
回答by mwallisch
You need a SMTP server to send your mail. If you have one available which does not require SMTP authentification (maybe your ISP's?) just edit the 'SMTP' ([mail function]) setting in your php.ini file.
您需要一个 SMTP 服务器来发送邮件。如果您有一个不需要 SMTP 身份验证的可用(也许是您的 ISP?),只需编辑 php.ini 文件中的“SMTP”([邮件功能])设置。
If this is no option because your SMTP server requires authentification you won't be able to use the internal mail() function and have to use some 3rd party class which supports smtp auth. e.g. http://pear.php.net/package/Mail/
如果这不是选项,因为您的 SMTP 服务器需要身份验证,您将无法使用内部 mail() 函数,并且必须使用一些支持 smtp 身份验证的 3rd 方类。例如http://pear.php.net/package/Mail/
回答by Fábio Duque Silva
I tried Test Mail Server Tool and while it worked great, you still need to open the email on some client.
我尝试了测试邮件服务器工具,虽然效果很好,但您仍然需要在某些客户端上打开电子邮件。
I found Papercut: https://papercut.codeplex.com/
我找到了剪纸:https: //papercut.codeplex.com/
For configuration it's easy as Test Mail Server Tool (pratically zero-conf), and it also serves as an email client, with views for the Message(great for HTML emails), Headers, Body(to inspect the HTML) and Raw(full unparsed email).
对于配置很容易,因为测试邮件服务器的工具(pratically零-conf的),并且它也可以作为一个电子邮件客户端,可欣赏的消息(伟大的HTML邮件),头,身体(来检查HTML)和原材料(全未解析的电子邮件)。
It also has a Sectionsview, to split up the different media types found in the email.
它还有一个部分视图,用于拆分电子邮件中的不同媒体类型。
It has a super clean and friendly UI, a good log viewer and gives you notifications when you receive an email.
它有一个超级干净和友好的用户界面,一个很好的日志查看器,并在你收到电子邮件时给你通知。
I find it perfect, so I just wanted to give my 2c and maybe help someone.
我觉得它很完美,所以我只是想给我的 2c,也许可以帮助别人。
回答by iyrin
Sendmail wasn't working for me so I used msmtp 1.6.2 w32and most just followed the instructions at DeveloperSide. Here is a quick rundown of the setup for posterity:
Sendmail 对我不起作用,所以我使用msmtp 1.6.2 w32并且大多数只是按照DeveloperSide的说明进行操作。以下是后代设置的简要概述:
Enabled IMAPaccess under your Gmail account (the one msmtp is sending emails from)
在您的 Gmail 帐户下启用 IMAP访问(从一个 msmtp 发送电子邮件)
Enable access for less secure apps. Log into your google account and go here
启用对不太安全的应用程序的访问。登录您的 Google 帐户并转到此处
Edit php.ini
, find and change each setting below to reflect the following:
编辑php.ini
、查找和更改下面的每个设置以反映以下内容:
; These are commented out by prefixing a semicolon
;SMTP = localhost
;smtp_port = 25
; Set these paths to where you put your msmtp files.
; I used backslashes in php.ini and it works fine.
; The example in the devside guide uses forwardslashes.
sendmail_path = "C:\wamp64\msmtp\msmtp.exe -d -C C:\wamp64\msmtp\msmtprc.ini -t --read-envelope-from"
mail.log = "C:\wamp64\msmtp\maillog.txt"
Create and edit the file msmtprc.ini
in the same directory as your msmtp.exe
file as follows, replacing it with your own email and password:
msmtprc.ini
在与您的msmtp.exe
文件相同的目录中创建和编辑文件,如下所示,将其替换为您自己的电子邮件和密码:
# Default values for all accounts
defaults
tls_certcheck off
# I used forward slashes here and it works.
logfile C:/wamp64/msmtp/msmtplog.txt
account Gmail
host smtp.gmail.com
port 587
auth on
tls on
from [email protected]
user [email protected]
password ReplaceWithYourPassword
account default : gmail
回答by ZeldaBoy
I used Mercury/32 and Pegasus Mail to get the mail() functional. It works great too as a mail server if you want an email address ending with your domain name.
我使用 Mercury/32 和 Pegasus Mail 来实现 mail() 功能。如果您想要一个以您的域名结尾的电子邮件地址,它也可以用作邮件服务器。