PhP邮件功能返回true但邮件未送达

时间:2013-01-23 12:08:58

标签: php email

我有一个域www.ipsmeerut.com,我使用下面的脚本发送邮件。它返回true但邮件没有发送。

这是我的剧本:

    <?php
    $to = 'brajnacs@gmail.com';
    $subject = 'Test';
    $headers = "From: Test<no-reply@ipsmeerut.com>\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
    $message = "<html><body>";
    $message .= "<h1>Hello, World!</h1>";
    $message .= "</body></html>";
    $res=false;
    $res=mail($to, $subject, $message, $headers);
    var_dump($res);
    echo "Mail sent to ".$to;
    ?>

此脚本在我的其他域上正常运行。 var_dump正在显示true。我的邮件服务器是aspmx.l.google.com,我还为其添加了MX Entry

2 个答案:

答案 0 :(得分:0)

使用phpmailer,试试这个

require_once('../class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = 'you content goes here';
$body             = eregi_replace("[\]",'',$body);

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

答案 1 :(得分:0)

为什么不使用默认MX并再次尝试测试?剂量谷歌允许发送带身份验证的匿名电子邮件?