【问题标题】:PHPMailer Class And Gmail: The sent emails not retain in Sent directory in GmailPHPMailer 类和 Gmail:已发送的电子邮件不会保留在 Gmail 的已发送目录中
【发布时间】:2012-12-04 13:55:17
【问题描述】:

我使用 PHPMailer 类发送邮件

http://code.google.com/a/apache-extras.org/p/phpmailer/

已发送的电子邮件不会保留在 Gmail 的已发送目录中。

我哪里错了?

    try {
    $mail = new PHPMailer(true); //New instance, with exceptions enabled

    $body             = file_get_contents('ct.html');
    $body             = preg_replace('/\\\\/','', $body); //Strip backslashes

        $mail->IsSMTP(); // telling the class to use SMTP
        $mail->Host       = "smtp.gmail.com"; // SMTP server
        $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                                   // 1 = errors and messages
                                                   // 2 = messages only
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
        $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
        $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
        $mail->Port       = 465;                   // set the SMTP port for the GMAIL server
        $mail->Username   = "*******@gmail.com";  // GMAIL username
        $mail->Password   = "*******";            // GMAIL password

        if($mail->SmtpConnect()){
            echo "SmtpConnect";
        }else{
            echo "ERROR";
        }

        $mail->IsSendmail();  // tell the class to use Sendmail

        $mail->AddReplyTo("*******@gmail.com", "*****");

        $mail->From = "*******@gmail.com";
        $mail->FromName = "*******";

        $to = "receiver@*******.***";

    $mail->AddAddress($to);

    $mail->Subject  = "First PHPMailer Message " . rand();

    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    $mail->WordWrap   = 80; // set word wrap

    $mail->MsgHTML($body);

    $mail->IsHTML(true); // send as HTML

    $mail->Send();
    echo 'Message has been sent.';
} catch (phpmailerException $e) {
    echo $e->errorMessage();
}

如何将电子邮件存储在已发送目录中?

提前致谢!

【问题讨论】:

标签: php gmail


【解决方案1】:

This 似乎与您的问题有关,并且似乎在使用 smtp 时它们没有被存储。但是,您可以密件抄送发送帐户,然后将这些邮件过滤到单独的文件夹中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-19
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 2013-09-06
    相关资源
    最近更新 更多