繁体   English   中英

使用Apache邮件发送电子邮件不会保存在已发送的文件夹中

[英]Sending email using Apache mail is not saved in the sent folder

我正在使用Apache Commons Mail库发送电子邮件(使用他们简单的SMTP电子邮件示例)。

电子邮件是使用其中一个着名的提供商发送的(我以雅虎为例)。 电子邮件已成功发送。 但是,当我登录到我的yahoo帐户时,我看不到发送文件夹中的电子邮件。

是否需要启用一个标志或我需要编码的其他一些东西,以确保电子邮件保存在已发送的文件夹中?

请协助。 谢谢

我刚刚遇到了同样的问题,解决了这个问题:

    ...
    // send the org.apache.commons.mail.HtmlEmail
    email.send();
    copyIntoSent(email.getMailSession(), email.getMimeMessage());
}

private void copyIntoSent(final Session session, final Message msg) throws MessagingException
{
    final Store store = session.getStore("imaps");
    store.connect(IMAP_HOST, SMTP_AUTH_USER, SMTP_AUTH_PWD);

    final Folder folder = (Folder) store.getFolder("Sent Items");
    if (folder.exists() == false) {
        folder.create(Folder.HOLDS_MESSAGES);
    }
    folder.open(Folder.READ_WRITE);

    folder.appendMessages(new Message[] { msg });
}

请注意,您必须在此处使用imap-host,而不是smtp-host。 这些协议的区别应该是清楚的。

亲切的问候

戴维

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM