使用pear在php中发送邮件

使用pear在php中发送邮件,php,email,smtp,pear,Php,Email,Smtp,Pear,我现在面临的问题真的很奇怪。 我以前使用过下面给出的脚本,它非常有效,但现在根本不起作用 代码如下: function send($str){ $from = "body<body@gmail.com>"; $to = "TargetName <matthew.s@gmail.com>"; $subject = "Questionnaire Submission!"; $body = $str; $host = "smtp.gmai

我现在面临的问题真的很奇怪。 我以前使用过下面给出的脚本,它非常有效,但现在根本不起作用

代码如下:

function send($str){
    $from = "body<body@gmail.com>";
    $to = "TargetName <matthew.s@gmail.com>";
    $subject = "Questionnaire Submission!";
    $body = $str;
    $host = "smtp.gmail.com";
    $username = "body";
    $password = "pwd";

    $headers = array ('From' => $from,
        'To' => $to,
        'Subject' => $subject);
    $smtp = Mail::factory('smtp',
        array ('host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password));
    $mail = $smtp->send($to, $headers, $body);
    if (PEAR::isError($mail)) {
        echo("An error occured during submission! Please try again!");
    } else {
        echo("Submission Successful!!\nYou will now be redirected to a page to fix the timings.");
    }
}

这与PEAR邮件无关;这是一个普遍的电子邮件问题。 PEAR的邮件包可以很好地发送邮件——最近的PHP版本如5.5和5.6beta1也是如此


尝试将邮件发送到其他电子邮件地址,这可能会起作用

也要遵循Gmail的指导原则,如您的回复中所述

如果收件人是Gmail用户,我们将包括:


因此,将邮件发送到gmail地址,您将获得更多信息。

if(PEAR::isError($mail)){
die($mail->getMessage());
之后插入此邮件,并告诉我们错误消息的内容。空白..我根本没有收到任何错误消息。添加
错误报告(E|error | E| E|PARSE)
到页面顶部更改它?如何更改
die($mail->getMessage());
die($mail->getCode());
否。它仍然是空的。
This is an automatically generated Delivery Status Notification

THIS IS A WARNING MESSAGE ONLY.

YOU DO NOT NEED TO RESEND YOUR MESSAGE.

Delivery to the following recipient has been delayed:
Message will be retried for 2 more day(s)

Technical details of temporary failure:
Message temporarily rejected.  See http://support.google.com/mail/bin/answer.py?answer=69585 for more information.