邮件功能在localhost服务器上不起作用 [英] mail function is not working in localhost server
本文介绍了邮件功能在localhost服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
$ to =someone@example.com;
$ subject =测试邮件;
$ message =你好!这是一个简单的电子邮件。
$ from =someonelse@example.com;
$ headers =From:。从$;
mail($ to,$ subject,$ message,$ headers);
echoMail Sent。
?>
解决方案
确保邮件服务器在php中正确配置.ini文件。
在php.ini文件中注释掉这些行,然后重新启动Apache服务器。
/ * [邮件功能]
; XAMPP:如果要使用像Mercury
的SMTP服务器,请注释出来; SMTP = localhost
; smtp_port = 25
* /
/ *;仅适用于Win32
; http://php.net/sendmail-from
; sendmail_from = postmaster @ localhost
* /
I am on my localhost server. I am using this code below, but I never received the email.
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
解决方案
Make sure that the mailserver is configured correctly in the php.ini file.
comment out these lines like this in php.ini file and restart the Apache server.
/*[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = localhost
; smtp_port = 25
*/
/*; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
*/
这篇关于邮件功能在localhost服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文