多个独立的邮件函数PHP


Multiple and Separate Mail Functions PHP

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

我建议你复制你的$headers,并将其命名为$headers2并使用

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

这可能是问题所在。