2017-11-24 5 views

Antwort

0

Sie sollten Ihren Code in Ihre Frage aufnehmen.

Dies ist nicht PHPMailer's Job, aber es ist verwandt. Werfen Sie einen Blick auf the end of the gmail example provided with PHPMailer. Es enthält einen Abschnitt, der eine gesendete Nachricht in Ihren IMAP-Ordner hochlädt. Die Grundidee ist, dass Sie nach einer erfolgreichen send() Antwort erhalten haben, eine Kopie der Nachricht erhalten und es zu einem IMAP-Postfach laden:

... 
//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 verwendet einen Wrapper um PHPMailer, aber Sie sollten bekommen können Zugriff auf die notwendigen Daten irgendwie, und der IMAP-Code ist nicht spezifisch für PHPMailer.

+0

Vielen Dank für Ihre Antwort, imap_append arbeitete für mich excellently – Sahak10

+2

Nur eine Anmerkung für andere: Google Mail, insbesondere, wenn über smtp.gmail.com gesendet, wird automatisch eine Kopie in den Ordner Gesendet. Dies ist jedoch kein Standardverhalten. – Max

+0

@ user5677872 - Wenn Ihnen meine Antwort gefallen hat und Ihr Problem gelöst wurde, markieren Sie sie bitte als die richtige Antwort. – Synchro

Verwandte Themen