PHP邮件功能无法在Hostgator上运行

时间:2015-09-30 06:24:15

标签: php email server web-hosting host

我必须在我的项目中使用邮件功能。当我在hostgator上托管我的项目时,它不起作用。但是当我在其他服务器上托管时,它工作正常。我无法理解问题。如果有人知道答案,请解释或建议我从一开始就能理解的链接。谢谢。这是我的代码。

$to_address = "test@somedomain.com";
$subject = "This goes in the subject line of the email!";
$message = "This is the body of the email.\n\n";
$message .= "More body: probably a variable.\n";
$headers = "From: test@somedomain.com\r\n";
mail("$to_address", "$subject", "$message", "$headers");

1 个答案:

答案 0 :(得分:9)

假设您在hostgator.in&特别是你提到的hostgator,如果域名不是你托管你网站的域名,它就不允许邮件发送。发件人或收件人的邮件应与托管邮件相同。如果ypu有一个网站a.com,那么发件人的邮件ID或收件人的邮件ID应该有@a.com