I'm using this contact_us.php file to enable 'Contact us' section of my website. If i use my gmail or hotmail address here for $mail_to = 'user@gmail.com'; it works perfectly. But if i use my email address associated to the website i mean like $mail_to = 'user@mywebsite.com'; i'm not getting any mail to my inbox. I even checked my spam and all other folder. Can anyone please help me with this? How can i get emails to the email address associated with my website. Thanks in advance.
我正在使用此contact_us.php文件啟用我網站的“聯系我們”部分。如果我在這里使用我的Gmail或hotmail地址$ mail_to ='user@gmail.com';它完美地運作。但如果我使用與網站相關聯的電子郵件地址,我的意思是$ mail_to ='user@mywebsite.com';我沒有收到任何郵件到我的收件箱。我甚至檢查了我的垃圾郵件和所有其他文件夾有人可以幫我這個嗎?如何收到與我的網站相關聯的電子郵件地址的電子郵件。提前致謝。
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'user@mywebsite.com';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\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) { ?>
alert('Thank you for the message. We will contact you shortly.');
window.location = 'index.html';
}
else { ?>
alert('Message failed. Please, send an email to user@yahoo.com');
window.location = 'index.html';
}
?>
1 个解决方案
#1
1
If you do not want to use mail function, than try SMTP mail from PHPmailer library.
如果您不想使用郵件功能,請嘗試從PHPmailer庫中搜索SMTP郵件。
You will be able to send email from your gmail or outlook or any other smtp account from your website. sharing you the link below:
您將能夠從您的網站發送來自您的Gmail或Outlook或任何其他smtp帳戶的電子郵件。分享以下鏈接:
Enjoy :)