简体   繁体   English

配置 WAMP 服务器以发送电子邮件

[英]Configure WAMP server to send email

有没有办法可以为 PHP 配置WAMP 服务器以启用mail()功能?

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.它对我来说立竿见影,希望这对你有帮助。

Install Fake Sendmail (download sendmail.zip ).安装Fake Sendmail (下载sendmail.zip )。 Then configure C:\\wamp\\sendmail\\sendmail.ini:然后配置C:\\wamp\\sendmail\\sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password

The above will work against a Gmail account.以上将适用于 Gmail 帐户。 And then configure php.ini:然后配置php.ini:

sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"

Now, restart Apache, and that is basically all you need to do.现在,重新启动 Apache,这基本上就是您需要做的全部工作。

Using an open source program call Send Mail , you can send via wamp rather easily actually.使用开源程序调用Send Mail ,您实际上可以很容易地通过 wamp 发送。 I'm still setting it up, but here's a great tutorial by jo jordan .我仍在设置它,但这是 jo jordan精彩教程 Takes less than 2 mins to setup.设置时间不到 2 分钟。

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.一旦我取消了错误日志的注释并发现它在 pop3 身份验证中停滞不前,我就删除了它并且它发送得很好。 Best of luck!祝你好运!

You need a SMTP server to send your mail.您需要一个 SMTP 服务器来发送邮件。 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 身份验证的可用(也许是您的 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.如果这不是选项,因为您的 SMTP 服务器需要身份验证,您将无法使用内部 mail() 函数,并且必须使用一些支持 smtp 身份验证的 3rd 方类。 eg http://pear.php.net/package/Mail/例如http://pear.php.net/package/Mail/

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://github.com/ChangemakerStudios/Papercut-SMTP (updated URL for 2021) https://github.com/ChangemakerStudios/Papercut-SMTP(2021 年更新的 URL)

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 Sections view, 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,也许可以帮助别人。

Sendmail wasn't working for me so I used msmtp 1.6.2 w32 and most just followed the instructions at DeveloperSide . Sendmail 对我不起作用,所以我使用msmtp 1.6.2 w32并且大多数只是按照DeveloperSide的说明进行操作。 Here is a quick rundown of the setup for posterity:以下是后代设置的简要概述:

Enabled IMAP access 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:在与msmtp.exe文件相同的目录中创建并编辑文件msmtprc.ini ,如下所示,将其替换为您自己的电子邮件和密码:

# 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 ReplaceWithYourEmail@gmail.com
user ReplaceWithYourEmail@gmail.com
password ReplaceWithYourPassword
account default : gmail

I used Mercury/32 and Pegasus Mail to get the mail() functional.我使用 Mercury/32 和 Pegasus Mail 来实现 mail() 功能。 It works great too as a mail server if you want an email address ending with your domain name.如果您想要一个以您的域名结尾的电子邮件地址,它也可以用作邮件服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM