我的$headers
和/或mail()
功能是不正确还是不正确?我的页面有一个表单,当您填写时将向收件人发送电子邮件,然后通过短信发送第二个(许多运营商具有文本到电子邮件功能)。当我提交表单时,第一个mail()
函数有效,但第二个没有。有什么想法吗?另外,我这样做是因为我希望它发送电子邮件和短信(我认为这是一个好主意),以便收件人收到通知,其中有一封需要他/她注意的电子邮件。
这就是我的意思。
// HTML FORM here, collects just name, email, subject line, message
// When the form is submitted it does this...
$to = "recepient@email.com";
$to_sms = "recepienttextnumber@tmomail.net";
$subject = filter_var($_POST['subject'], FILTER_SANITIZE_STRING)." - FORM";
$headers = 'MIME-Version: 1.0' . "\r\n" .
'Content-type:text/html;charset=iso-8859-1' . "\r\n" .
'From: noreply@email.com' . "\r\n" .
'Reply-To: info@email.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$body = "
<html>
<p>This is an automatic email notification. <strong>Please do not reply to this email</strong></p>
<p>You received a message from ". $name . " that needs your attention ASAP.!</p>
<p>Client name: ".$name."<br />
Client phone: ".$phone."<br />
Email: ".$email."<br />
About: ".$_POST['subject']."<br />
Message: ".$message."</p>
</html>";
$body_sms = "Great news! ".$name." has contacted you via the FORM. Check your email now.";
// Send Email & Text Notification
//Here sends out the form via email
mail($to, $subject, $body, $headers);
//alternatively a second message is sent to another
mail($to_sms, $subject, $body_sms, "From: FORM");
//Echos a thank you.
答案 0 :(得分:0)
我建议您复制$headers
并将其命名为$headers2
并使用
mail($to, $subject, $body_sms, $headers2);
可能是问题。