2017-11-24 3 views

답변

0

질문에 코드를 포함해야합니다.

이것은 PHPMailer의 직업은 아니지만 관련이 있습니다. the end of the gmail example provided with PHPMailer을보십시오. 보낸 메시지를 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 래퍼를 사용하지만, 당신이 얻을 수 있어야합니다 : 기본 개념은 성공적인 send() 응답을받은 후, 메시지의 사본을 얻을하고 IMAP 사서함에 업로드 할 것입니다 어떻게 든 필요한 데이터에 액세스 할 수 있으며 IMAP 코드는 PHPMailer에만 국한되지 않습니다.

+0

답장을 보내 주셔서 감사합니다. imap_append이 (가) 나를 위해 일했습니다. excelentlly – Sahak10

+2

Gmail의 경우 smtp.gmail.com을 통해 보낸 메일은 자동으로 보낸 편지함에 사본이 저장됩니다. 이것은 비표준 동작입니다. – Max

+0

@ user5677872 - 내 대답을 좋아하고 문제가 해결되면 정답으로 표시하십시오. – Synchro

관련 문제