JAVA邮件发送问题

今天写了一个发送mail的代码
一直报错:com.sun.mail.smtp.SMTPSendFailedException: 550 Invalid User
在网上找了很久也没有解决!
后来想到,可能是邮件服务器提供商的过滤机制造成:
在代码中将邮件发送方给正确填写即可:
错误代码为:
MimeMessageHelper help = new MimeMessageHelper(mimeMessage,true, "utf-8");
help.setFrom("OY");
help.setTo("[email protected]");
help.setSubject("主题");
help.setText("内容", true);

javaMailSender.send(mimeMessage);
正确为:
MimeMessageHelper help = new MimeMessageHelper(mimeMessage,true, "utf-8");
help.setFrom("[email protected]");
help.setTo("[email protected]");
help.setSubject("主题");
help.setText("内容", true);

javaMailSender.send(mimeMessage);

你可能感兴趣的:(java)