简体   繁体   English

使用梨在php中发送邮件

[英]Sending mail in php using pear

The problem I am facing at the moment is really odd. 我目前面临的问题确实很奇怪。 I've used the script given below before and it has worked like a charm, but now it is simply not working. 我以前使用过下面给出的脚本,它的工作原理像个魅力,但现在根本不起作用。

Here is the code: 这是代码:

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

Now this code wont send the mail can I cannot understand why. 现在,此代码不会发送邮件,我无法理解为什么。

Some help would be appreciated. 一些帮助,将不胜感激。

Best Regards Priyabrata 最好的问候Priyabrata

edit 编辑

I received a mail from the account I was using to send the mail : 我收到了用于发送邮件的帐户的邮件:

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.

This has nothing to do with PEAR mail; 这与PEAR邮件无关。 it's a general email issue. 这是一个普通的电子邮件问题。 PEAR's Mail package can send mails fine - also with recent PHP versions like 5.5 and 5.6beta1. PEAR的Mail包可以很好地发送邮件-也可以使用最新的PHP版本(如5.5和5.6beta1)。


Try to send the mail to a different email address, this might work. 尝试将邮件发送到其他电子邮件地址,这可能会起作用。

Also follow Gmail's guidelines as depicted in the support URL in your response. 另外,请按照您的回复中支持网址中所述的Gmail指南进行操作。

In situations where the recipient is a Gmail user, we will include: 如果收件人是Gmail用户,则我们将包括:

... ...

So send the mail to a gmail address, and you will get more information. 因此,将邮件发送到gmail地址,您将获得更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM