authentication is required,163 smtp12,EMCowAAXfwfWaTpdysD_Cg--.58754S2 1564109270

发送邮件报错

org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 553 authentication is required,163 smtp12,EMCowAAXfwfWaTpdysD_Cg--.58754S2 1564109270

    at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:488)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:359)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:354)

原代码-发送失败(这种方式在spring-context-support-4.3.6.RELEASE下没问题,在spring-context-support-5.0.4.RELEASE下有问题)

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

修改后代码-发送成功

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

 

完整代码:

JavaMailSenderImpl tempMailSender = new JavaMailSenderImpl();
tempMailSender.setHost("smtp.163.com");
tempMailSender.setPort(25);
tempMailSender.setProtocol("smtp");
tempMailSender.setUsername("xxxxx@163.com");
tempMailSender.setPassword("xxxxx");
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.connectiontimeout", 10000);
props.put("mail.smtp.timeout",10000);
tempMailSender.setJavaMailProperties(props);
        
MimeMessage mimeMessage = tempMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "utf-8");

helper.setFrom("xxxxxx@163.com");
helper.setTo("xxxxxx@qq.com");
helper.setSubject("2222");
helper.setText("=-=-=-=--", true);

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值