我使用最新的WAMP,当我尝试发送电子邮件时,我得到了这个:
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:\wamp\www\main\createaccount.php on line 8
Run Code Online (Sandbox Code Playgroud)
邮件传递失败...
消息:
$to = "xxx@hotmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
Run Code Online (Sandbox Code Playgroud)
你还需要下载"邮件服务器"吗?
请帮忙.
小智 15
这对我有用,应该适合你:使用假的Sendmail和一个虚拟主机邮件服务器(即 - Godaddy,1and1等).
1.)下载sendmail zip并将其解压缩到C:\ Wamp\bin\sendmail(出于此示例的目的).
2.)编辑C:\ wamp\bin\sendmail\sendmail.ini并将以下内容设置为您的邮件服务器的要求(我的下面是):
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=
Run Code Online (Sandbox Code Playgroud)
3.)在php.ini文件中设置sendmail.exe的路径.
[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:\wamp\bin\sendmail\sendmail.exe -t"
Run Code Online (Sandbox Code Playgroud)
4.)重启Wampserver.
您可能使用Gmail取得了成功,但还有一些额外的调整可以使其发挥作用.我更喜欢使用我上传代码的webhost的邮件服务器.
您的计算机上没有运行 smtp 服务器,但您不必这样做。只需将 SMTP 设置为开放的 smtp 服务器即可,例如:
ini_set('SMTP', 'smtp.yourisp.com');
Run Code Online (Sandbox Code Playgroud)
查看 ISP 的主页或http://www.e-eeasy.com/SMTPServerList.aspx以获取 SMTP 服务器列表。
如果您有桌面邮件程序,则可以使用与发送邮件相同的地址。