javamail 发送邮件有问题

a302517289 2017-07-10 03:44:29
535 Error: authentication failed system busy
...全文
143 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
a302517289 2017-07-10
  • 打赏
  • 举报
回复
public class SendEmail extends Thread { private String click_href; private String click_here; private String host; private String password; private String email; private String email_name; private List<StrategyProjectUser> users; private String text; private static ApplicationContext ctx=null; private static JavaMailSenderImpl mailSender; static{ mailSender = (JavaMailSenderImpl) SpringBeanUtil.getBeanByName("mailSender"); } @Override public void run() { try { sleep(5000L); Properties pro = new Properties(); FileInputStream in = new FileInputStream(this.getClass().getResource("/").getPath()+"resource.properties"); pro.load(in); this.click_href = pro.getProperty("mail.click.here"); this.click_here = pro.getProperty("mail.click.local"); this.email = pro.getProperty("mail.smtp.username"); this.email_name = pro.getProperty("mail.smtp.name"); this.host = pro.getProperty("mail.smtp.host"); this.password = pro.getProperty("mail.smtp.password"); in.close(); } catch (Exception e) { e.printStackTrace(); } if (users != null){ for (StrategyProjectUser user: users){ // String str=bo.getSupplier_category().equals("1")?"方案类":"施工图类"; String content = "<p>" + text + ",点击<a href=\""+click_here+"\">进入网址</a>!</p>"; Pattern p = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); Matcher m = p.matcher(user.getEmail()); boolean b = m.matches(); if(b){ send("ming_chen@wishbuild.com", content,"复地战略供应商评审"); // send("976747663@qq.com", content,"复地战略供应商评审"); } } } } public void send(String email, String content,String title) { String addressee = email; //String title = "复地战略供应商评审"; String from = email_name; String from_email = this.email; mailSenderOK(addressee, content, title, from, from_email); } public void mailSenderOK(final String addressee, final String context, final String title, final String from, final String from_email) { MimeMessagePreparator preparator = new MimeMessagePreparator() { public void prepare(MimeMessage mimeMessage) throws Exception { MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8"); message.setTo(addressee); message.setFrom(from_email, from); if (title == null) { message.setSubject(""); } else { message.setSubject(title); } message.setText(context, true); } }; this.mailSender.send(preparator); } public List<StrategyProjectUser> getUsers() { return users; } public void setUsers(List<StrategyProjectUser> users) { this.users = users; } public String getText() { return text; } public void setText(String text) { this.text = text; } } 这是邮件发送类

51,412

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧