通过Yahoo使用JavaMail API发送的邮件不会发送到已发送邮件文件夹 [英] Messages sent via yahoo using javamail api not going to sent messages folder

查看:230
本文介绍了通过Yahoo使用JavaMail API发送的邮件不会发送到已发送邮件文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用javamail api从我的Yahoo地址发送消息时,它们不会进入已发送的文件夹.有什么问题?这是我的源代码:

When i send messages from my yahoo address using javamail api, they don't go to the sent folder. What's the problem? Here's my source code:

public void doSendYahooMail(){
    from = txtFrom.getText();
    password= new String(txtPassword.getPassword());
    to = txtTo.getText();
    subject = txtSubject.getText();
    email_body = jTextArea1.getText();

    Properties props = new Properties();
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.host", "smtp.mail.yahoo.com");
    props.put("mail.smtp.port", "465");
    props.put("mail.smtp.socketFactory.port", "465");
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

    Session session = Session.getInstance(props,
            new javax.mail.Authenticator(){
                @Override
                protected PasswordAuthentication getPasswordAuthentication(){
                    return new PasswordAuthentication(from, password);
                }
    }
    );
    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
        message.setSubject(subject);
        message.setText(email_body);
        Transport.send(message);

        JOptionPane.showMessageDialog(this, "Message Sent!","Sent",JOptionPane.INFORMATION_MESSAGE);

    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e.toString());
    }
}

我需要进行哪些修改

推荐答案

如果要在已发送邮件文件夹中放置副本,则需要自己将其放置在其中.有关示例,请参见 JavaMail示例程序msgsend.java .

If you want a copy in your sent messages folder, you need to put it there yourself. See the JavaMail sample program msgsend.java for an example.

此外,您还需要修复这些常见的JavaMail错误在您的程序中.

Also, you'll want to fix these common JavaMail mistakes in your program.

这篇关于通过Yahoo使用JavaMail API发送的邮件不会发送到已发送邮件文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆