0

我的$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.
4

1 回答 1

0

我建议您复制一份$headers并命名$headers2并使用

mail($to, $subject, $body_sms, $headers2);

这可能是问题所在。

于 2013-10-28T00:39:02.890 回答