【问题标题】:Sending mail in php using pear使用 pear 在 php 中发送邮件
【发布时间】:2014-05-25 22:58:32
【问题描述】:

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

代码如下:

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.");
    }
}

现在这段代码不会发送邮件,我不明白为什么。

我们将不胜感激。

最好的问候 普利亚布拉塔

编辑

我收到了一封来自我用来发送邮件的帐户的邮件:

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.

【问题讨论】:

  • if (PEAR::isError($mail)) { 之后插入:die($mail-&gt;getMessage()); 并告诉我们错误消息的内容。
  • 空白.. 我根本没有收到任何错误消息。
  • 在页面顶部添加error_reporting(E_ERROR | E_PARSE); 会改变这种情况吗?
  • die($mail-&gt;getMessage());改成die($mail-&gt;getCode());怎么样
  • 没有。它仍然是空白的。

标签: php email smtp pear


【解决方案1】:

这与 PEAR 邮件无关;这是一个一般的电子邮件问题。 PEAR 的 Mail 包可以很好地发送邮件 - 也适用于最近的 PHP 版本,如 5.5 和 5.6beta1。


尝试将邮件发送到其他电子邮件地址,这可能会奏效。

还请遵循您回复中 support URL 中所述的 Gmail 指南。

在收件人是 Gmail 用户的情况下,我们将包括:

...

所以把邮件发到一个gmail地址,你会得到更多的信息。

【讨论】:

    猜你喜欢
    • 2010-12-05
    • 1970-01-01
    • 2012-01-07
    • 2011-04-10
    • 2015-04-09
    • 2020-08-24
    • 2014-01-05
    • 1970-01-01
    相关资源
    最近更新 更多