简体   繁体   English

PHP邮件功能在Windows中不起作用

[英]PHP mail function is not working in windows

My PHP code for sending mail is: 我用于sending mail PHP代码是:

$email_to="deepuskmr@gmail.com";
$email_subject="It works";
$email_message="Hello. I can send mail!";
$headers = "From:Dpu\r\n".
"Reply-To: sdeepu.kmr@gmail.com\r\n'" .
"X-Mailer: PHP/" . phpversion();
mail($email_to, $email_subject, $email_message, $headers);  
echo "mail sent!"

But this code not sending email. 但是此代码不发送电子邮件。 It gives the error. 它给出了错误。 在此处输入图片说明

My php.ini file settings are 我的php.ini文件设置是

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = sdeepu.kmr@gmail.com

I am working in localhost . 我在localhost工作。 And I am using windows 64 machine. 我正在使用windows 64计算机。

You are using localhost as mail server, if you did not installed one (SMTP server), this will obviously returns you cannot connect. 您将localhost用作邮件服务器,如果未安装localhost (SMTP服务器),则显然这将返回您无法连接。

You should have something like : 你应该有这样的东西:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587

I use the free and awesome hMail on my dev box so that I can test my email functions and not just get mail() errors! 我在开发箱上使用了免费且功能强大的hMail,以便可以测试我的电子邮件功能,而不仅仅是收到mail()错误!

http://www.stylus.co.za/setting-up-hmail-on-your-development-box/ http://www.stylus.co.za/setting-up-hmail-on-your-development-box/

我已经在Fasthost上托管了一个站点,它是Windows服务器。出于安全原因,我们无法通过在Fasthosts平台中使用任意地址作为“发件人”地址来发送电子邮件,“发件​​人”地址必须是存在于邮箱中的邮箱。 Fasthosts平台。

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

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