簡體   English   中英

通過PHP郵件發送的郵件未顯示在我的郵件“已發送”文件夾中

[英]Mail sent with PHP mail are not shown in my mails Sent folder

我正在將電子郵件從我的Webmail帳戶發送到任何電子郵件地址。

郵件發送成功,但是如何在我的Webmail帳戶的sendmail文件夾中保存此郵件。

我使用codeigniter電子郵件發送功能。

您應該在問題中包含代碼。

這不是PHPMailer的工作,而是相關的。 看一下PHPMailer提供的gmail示例的結尾 它包括一個部分,該部分將已發送的郵件上載到您的IMAP文件夾。 基本思想是,在收到成功的send()響應后,獲取消息的副本並將其上載到IMAP郵箱:

...
//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
    //Section 2: IMAP
    if (save_mail($mail)) {
        echo "Message saved!";
    }
}
//Section 2: IMAP
//IMAP commands requires the PHP IMAP Extension, found at: https://php.net/manual/en/imap.setup.php
//Function to call which uses the PHP imap_*() functions to save messages: https://php.net/manual/en/book.imap.php
//You can use imap_getmailboxes($imapStream, '/imap/ssl') to get a list of available folders or labels, this can
//be useful if you are trying to get this working on a non-Gmail IMAP server.
function save_mail($mail)
{
    //You can change 'Sent Mail' to any other folder or tag
    $path = "{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail";
    //Tell your server to open an IMAP connection using the same username and password as you used for SMTP
    $imapStream = imap_open($path, $mail->Username, $mail->Password);
    $result = imap_append($imapStream, $path, $mail->getSentMIMEMessage());
    imap_close($imapStream);
    return $result;
}

CodeIgniter使用PHPMailer的包裝器,但是您應該能夠以某種方式訪問​​必要的數據,並且IMAP代碼並非特定於PHPMailer。

暫無
暫無

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

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