Javamail SMTPSenderFailedException 553

时间:2015-11-04 12:31:13

标签: smtp gmail javamail

这段代码在几个月内运行良好,但突然停止工作而代码没有任何变化。异常堆栈跟踪具有:

 com.sun.mail.smtp.SMTPSenderFailedException: 553 5.1.2 The address specified is not a valid RFC-5321 address. tj2sm1495299pab.4 - gsmtp

我的代码,之前有效:

    final String username = uName;

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "587");
    props.put("mail.smtp.debug", "true");

    Session session = Session.getInstance(props, new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);
        }
    });

    try {
        Message message = new MimeMessage(session);

        message.setFrom(new InternetAddress("<from email id>"));
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("<to email address>"));
        message.setSubject("<subject>");
        message.setContent(finalMessage, "text/html");

        Transport.send(message);

    } catch (MessagingException | UnsupportedEncodingException e) {
        e.printStackTrace();
        logger.error("Emailing error: "+e.getMessage());
    }

今天停止了工作。

2 个答案:

答案 0 :(得分:1)

对我来说,更改用户名字段内容来自&#34;用户名&#34;到&#34; username@gmail.com"。

答案 1 :(得分:0)

更改完整电子邮件地址的“来自电子邮件ID”

谷歌上周更改了标准RFC 5321的验证,涵盖了“FROM”字段