contact us的PHP文件,contact_us.php沒有發送電子郵件到我的網站相關郵件地址

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 :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值