簡體   English   中英

PHPMailer類和Gmail:發送的電子郵件未保留在Gmail的“已發送”目錄中

[英]PHPMailer Class And Gmail: The sent emails not retain in Sent directory in Gmail

我使用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();
}

我如何在已發送目錄中存儲電子郵件?

預先感謝 !

似乎與您的問題有關,並且似乎在使用smtp時不會存儲它們。 但是,您可以對發送帳戶進行密送,並僅將這些郵件過濾到單獨的文件夾中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM