由于某些原因,PHP邮件无法正常工作 [英] PHP mail not working for some reason
问题描述
我是PHP的新手,我正在使用邮件功能发送无法正常工作的电子邮件.我收到一条成功消息,但仍然无法正常工作
I am new to PHP and I'm using the mail function to send emails which is not working. I get a success message, but still it does not work
相同的代码
<?php
$email_to = "abc@abc.com";
$email_subject = "Test mail";
$email_body = "Hello! This is a simple email message.";
if(mail($email_to, $email_subject, $email_body)){
echo "The email($email_subject) was successfully sent.";
} else {
echo "The email($email_subject) was NOT sent.";
}
?>
我缺少任何内容吗,我需要为此功能包括任何文件吗?.我来自asp.net&这是在网站上找到的基本脚本.
Am I missing anything, do I need to include any files for this function.. I am from asp.net & this is the basic script which found on website.
我尝试了其他与邮件相关的脚本,这些脚本也无法正常工作.
I tried other scripts related to mail they didn't work either..
我正在网站上而不是在本地主机上运行此脚本
I AM RUNNING THIS SCRIPT ON THE WEBSITE NOT on the localhost
推荐答案
这可能是配置错误.如果您坚持使用PHP mail
函数,则必须编辑php.ini
.
This is probably a configuration error. If you insist on using PHP mail
function, you will have to edit php.ini
.
(在我看来)如果您正在寻找更简单,更通用的选项,则应使用 PHPMailer .
If you are looking for an easier and more versatile option (in my opinion), you should use PHPMailer.
这篇关于由于某些原因,PHP邮件无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!