0

我有一个域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了它。

4

2 回答 2

0

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

于 2013-01-23T12:37:33.087 回答
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!";
}
于 2013-01-23T12:25:02.260 回答