通过PHP邮件发送的邮件未显示在我的邮件“已发送”文件夹中 [英] Mail sent with PHP mail are not shown in my mails Sent folder
问题描述
我正在从我的Webmail帐户向任何电子邮件地址发送电子邮件。
I'm sending email from my webmail accounts to any email address.
邮件已成功发送,但是如何在我的Webmail中接收此邮件帐户已发送文件夹。
Mails are sending successfully, but how can I have this mails in my webmail account sent folder.
我使用codeigniter电子邮件发送功能。
I use codeigniter email sent functionality.
推荐答案
您应该在问题中包含代码。
You should include your code in your question.
此不是PHPMailer的工作,而是相关的。看看 PHPMailer随附的gmail示例的结尾。它包括一个部分,该部分将已发送的邮件上载到您的IMAP文件夹。基本想法是,在成功收到 send()
响应后,获取消息的副本并将其上传到您的IMAP邮箱:
This isn't PHPMailer's job, but it's related. Take a look at the end of the gmail example provided with PHPMailer. It includes a section that uploads a sent message to your IMAP folder. The basic idea is that after you've received a successful send()
response, get a copy of the message and upload it to your IMAP mailbox:
...
//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 uses a wrapper around PHPMailer, but you should be able to get access to the necessary data somehow, and the IMAP code is not specific to PHPMailer.
这篇关于通过PHP邮件发送的邮件未显示在我的邮件“已发送”文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!