PHP联系表单到邮件无法正常工作

时间:2016-08-08 11:11:56

标签: php forms email contact

大家好日子,这是我第一次在这里发帖,所以请耐心等待。我需要你的帮助,我是一个知道基本的html5 / css的艺术家,这就是为什么我真的不擅长php。

无论如何,我有一个有联系表格的项目,我刚刚意识到,当我在网上填写表格时,雅虎邮件无效,但gmail很好。下面是我的PHP代码。我一直关注这个PHP Mail() Contact-us form works fine if entering a Gmail sending address, but not with Yahoo,但我真的不能自己做!兄弟需要你的帮助。谢谢。

<?php
$field_name = $_POST['cf_name'];
$field_brand = $_POST['cf_brand'];
$field_category = $_POST['cf_category'];
$field_email = $_POST['cf_email'];
$field_facebook = $_POST['cf_facebook'];
$field_instagram = $_POST['cf_instagram'];
$field_number = $_POST['cf_number'];
$field_message = $_POST['cf_message'];

$mail_to = 'dulcetlifestylehub@gmail.com';
$subject = 'DULCET LIFESTYLE - BECOME FAMILY: '.$field_name;

$body_message = 'From Owner: '.$field_name."\n";
$body_message .= 'Brand Name: '.$field_brand."\n";
$body_message .= 'Brand Category: '.$field_category."\n";
$body_message .= 'Email: '.$field_email."\n";
$body_message .= 'Facebook: '.$field_facebook."\n";
$body_message .= 'Instagram: '.$field_instagram."\n";
$body_message .= 'Number: '.$field_number."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
    <script language="javascript" type="text/javascript">
        alert('Thank you for the message. We will contact you shortly.');
        window.location = 'becomefamily.htm';
    </script>
<?php
}
else { ?>
    <script language="javascript" type="text/javascript">
        alert('Message failed. Please, send an email to dulcetlifestylehub@gmail.com');
        window.location = 'becomefamily.htm';
    </script>
<?php
}
?>

0 个答案:

没有答案