使用PHP通过电子邮件发送的表单停止了仅向某些收件人发送电子邮件

时间:2019-05-20 18:28:04

标签: javascript php html forms email

我已经使用相同的代码大约一年半了,并且一切正常。 这段代码使用JavaScript和PHP将HTML表单发送到3个电子邮件地址。 大约一个月前,我停止接收电子邮件,但我知道其他两个仍在接收新电子邮件。

那怎么可能? 非常感谢您的帮助。

这是HTML中的JavaScript:

<script>
function submitContactForm(){
    var reg = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
    var name = $('#inputName').val();
    var email = $('#inputEmail').val();
    var message = $('#inputMessage').val();
    if(name.trim() == '' ){
    alert('Please enter your phone number');
        $('#inputName').focus();
    return false;
  }else if(message.trim() == '' ){
    alert('Please enter your phone number');
        $('#inputMessage').focus();
    return false;
  }else{
        $.ajax({
            type:'POST',
            url:'submit_form.php',
            data:'contactFrmSubmit=1&name='+name+'&email='+email+'&message='+message,
            beforeSend: function () {
                $('.submitBtn').attr("disabled","disabled");
                $('.modal-body').css('opacity', '.5');
            },
            success:function(msg){
                if(msg == 'ok'){
                    $('#inputName').val('');
                    $('#inputEmail').val('');
                    $('#inputMessage').val('');
                    $('.statusMsg').html('<meta http-equiv="refresh" content="0; url=thanks.html" />');
                }else{
                    $('.statusMsg').html('<span style="color:red;">Some problem occurred, please try again.</span>');
                }
                $('.submitBtn').removeAttr("disabled");
                $('.modal-body').css('opacity', '');
            }
        });
    }
}
</script>

这是PHP文件:

// Submitted form data
$name   = $_POST['name'];
$email  = $_POST['email'];
$message= $_POST['message'];

/*
 * Send email to admin
 */
$to     = 'email1@gmail.com, email2@gmail.com, email3@gmail.com';
$subject= 'title';

$htmlContent = '
<h4 dir="rtl">details</h4>
<table cellspacing="0" style="width: 300px; height: 200px;" dir="rtl">
    <tr>
        <th>name</th><td>'.$name.'</td>
    </tr>
    <tr style="background-color: #e0e0e0;">
        <th>phone</th><td>'.$message.'</td>
    </tr>
</table>';

// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// Additional headers
$headers .= 'From: edi<email1@gmail.com>' . "\r\n";

// Send email
if(mail($to,$subject,$htmlContent,$headers)){
    $status = 'ok';
}else{
    $status = 'err';
}

// Output status
echo $status;die;

}

0 个答案:

没有答案