java代码0用163邮箱发送邮件时报这个错

com.sun.mail.smtp.SMTPSendFailedException: 553 authentication is required,163 smtp14,EsCowEBZ50rSm3JWmXF+AA--.3541S2 1450351570

java代码:

public class EmailTools {

public static boolean send(String to,String subject,String content){
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");

    props.put("mail.host","smtp.163.com");

    props.put("mail.from", "15234874536@163.com");

    props.put("mail.smtp.anth", true);

    Session session = Session.getDefaultInstance(props);

    session.setDebug(true);
    try {
        Transport transport = session.getTransport();

        // 连接邮件服务器,链接您的163、sina邮箱,用户名(不带@163.com,登录邮箱的邮箱账号,不是邮箱地址)、密码
        transport.connect("15234874536","*************");

        MimeMessage message = new MimeMessage(session);

        message.setSubject(subject);

        message.setContent(content,"text/html;charset=utf-8");

        message.setSentDate(new Date());

        transport.sendMessage(message, InternetAddress.parse(to));
        return true;
    } catch (NoSuchProviderException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MessagingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return false;

}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    EmailTools email = new EmailTools();
    email.send("2747917518@qq.com","Hello World!", "你好你好你好你好你好");
}

}

2个回答

不知有没有开启163的POP/IMAP服务,开通了的话,会发一串密码给你,然后你就用这个密码登入就行了。

嗯,同上!我之前就是这样

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问