使用 PHP 邮件发送的邮件未显示在我的“已发邮件”文件夹中
Mail sent with PHP mail are not shown in my mails Sent folder
我正在从我的网络邮件帐户向任何电子邮件地址发送电子邮件。
邮件发送成功,但是我怎样才能在我的网络邮件帐户发送文件夹.
中收到这些邮件
我使用 codeigniter 电子邮件发送功能。
你应该在你的问题中包含你的代码。
这不是 PHPMailer 的工作,但它是相关的。看看the end of the gmail example provided with PHPMailer。它包括一个将已发送邮件上传到您的 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。
我正在从我的网络邮件帐户向任何电子邮件地址发送电子邮件。
邮件发送成功,但是我怎样才能在我的网络邮件帐户发送文件夹.
中收到这些邮件我使用 codeigniter 电子邮件发送功能。
你应该在你的问题中包含你的代码。
这不是 PHPMailer 的工作,但它是相关的。看看the end of the gmail example provided with PHPMailer。它包括一个将已发送邮件上传到您的 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。