dongying3744 2013-01-23 12:08
浏览 48

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

I have a domain www.ipsmeerut.com, i m using the script below to send mail. It is returning true but mail is not sending.

Here's my script:

    <?php
    $to = 'brajnacs@gmail.com';
    $subject = 'Test';
    $headers = "From: Test<no-reply@ipsmeerut.com>
";
    $headers .= "MIME-Version: 1.0
";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1
";
    $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;
    ?>

This script is working fine on my other domains. var_dump is showing true. My mail server is aspmx.l.google.com and I have also added MX Entry for it.

  • 写回答

2条回答 默认 最新

  • douse8732 2013-01-23 12:25
    关注

    Use phpmailer, Try this

    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!";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据