如何使用邮件功能在收件箱中发送邮件

时间:2015-12-01 11:29:07

标签: php

我正在尝试使用邮件功能发送邮件,但它总是在垃圾邮件文件夹中发送,此邮件来自@ gator4120.hostgator.com

<?php
$subject = "Registration completed !!!! ";
$from= "From: admin@xxxx.com\n";
$message ="Dear ".$varfname.",\n";
$message = $message."\r\nCongratulations! \n";
$message = $message."You are now a member of B2B Portal.\n";
$message = $message."Your profile is under screening and will be activated within next 24 hrs.\n ";
$header .= "Reply-To: admin <$from>\r\n";
$header .= "Return-Path: admin <$from>\r\n";
$header .= "From: admin <$from>\r\n";
$header .= "Organization: The organization\r\n";
$header .= "Content-Type: text/plain\r\n";
if ( mail("webpixeltest@gmail.com", $subject, $message, $header)) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?> 

1 个答案:

答案 0 :(得分:0)

您正在使用的主机站点是hostgator来托管您的站点。 mail()只是一个内置函数,可以将邮件传递到本地SMA(例如sendmail),从那时起依赖于您机器的配置。这里的配置设置为gator4120.hostgator.com作为邮件服务器,许多其他人也使用hostgator。因此,使用邮件服务器发送电子邮件的其他人可能已被标记为垃圾邮件,因此您的电子邮件自然也会被标记为垃圾邮件。解决方案是使用另一个邮件服务器,如MailChimp link

尝试使用

  1. phpmailer
  2. swiftmailer
相关问题