使用 WAMP 发送电子邮件 [英] Sending emails with WAMP

查看:41
本文介绍了使用 WAMP 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用最新的 WAMP,当我尝试发送电子邮件时收到此信息:

I use the latest WAMP and I get this when I try to send emails:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:wampwwwmaincreateaccount.php on line 8

消息传递失败...

消息:

$to = "xxx@hotmail.com";
$subject = "Hi!";
$body = "Hi,

How are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }

您还需要下载邮件服务器"吗?

Do you need do download a "mailserver" also?

请帮忙.

推荐答案

这对我有用,也应该对你有用:使用 假 Sendmail 和虚拟主机邮件服务器(即 - Godaddy、1and1 等).

This works for me and should work for you: Use Fake Sendmail and a webhost mail server (i.e. - Godaddy, 1and1, etc.).

1.) 下载 sendmail zip 并将其解压缩到 C:Wampinsendmail(对于本示例而言).

1.) Download the sendmail zip and extract it to C:Wampinsendmail (for purposes of this example).

2.) 编辑 C:wampinsendmailsendmail.ini 并将以下内容设置为您的邮件服务器的要求(我的如下):

2.) Edit C:wampinsendmailsendmail.ini and set the following to your mail server's requirements (mine are below):

smtp_server=mail.yourdomain.com
smtp_port=26
smtp_ssl=none
;default_domain=yourdomain.com
auth_username=smtpuser@yourdomain.com
auth_password=smtppassword
;pop3_server=
;pop3_username=
;pop3_password=
;force_sender=
;force_recipient=

3.) 在 php.ini 文件中设置 sendmail.exe 的路径.

3.) Set the path of sendmail.exe in your php.ini file.

[mail function]
; For Win32 only.
SMTP =

; For Win32 only.
sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:wampinsendmailsendmail.exe -t"

4.) 重启 Wampserver.

4.) Restart Wampserver.

您可能会成功使用 Gmail,但需要进行一些额外的调整才能使其发挥作用.我更喜欢使用我上传代码的虚拟主机的邮件服务器.

You might have success using Gmail, but there are a few extra tweaks to make it work. I prefer using the mail server of the webhost where I upload my code.

这篇关于使用 WAMP 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆