如何使用PHP从网站发送电子邮件?

时间:2018-11-12 11:02:01

标签: php email web html-email mailto

我已经开发了一个网站,并希望从该网站域发送电子邮件 我已经配置了邮件功能,然后才能正常工作,但是几个月后,我的代码无法正常工作

$email_from = 'xxx@domainname.lk';//<== update the email address
$email_subject = "New Visitor";
$email_body = "new visitor".

$to = 'qqq@gmail.com';//<== update the email address
$headers .= "From: $email_from \r\n";

//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');

1 个答案:

答案 0 :(得分:0)

我认为$ email_body变量的值应以分号(;)结尾,并且$ header应该如下所示

$headers = 'From: webmaster@example.com' . "\r\n" .
      'Reply-To: webmaster@example.com' . "\r\n" .
      'X-Mailer: PHP/' . phpversion();
相关问题