Spring中配置的javamail
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"
p:defaultEncoding="utf-8"
p:host="smtp.163.com"
p:username="18718301376"
p:password="*********">
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
<bean id="emailSender" class="cn.myproject.oa.core.util.email.impl.EmailSenderImpl"
p:javaMailSender="#{javaMailSender}"
p:from="18718301376@163.com"/>
java代码
@Override
public boolean sender(String to, String subject, String message,
boolean isHtml) {
try {
/** 创建邮件 */
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
/** 创建邮件帮助类 */
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage);
/** 设置收件人 */
helper.setTo(to);
/** 设置发送人 */
helper.setFrom(from);
/** 设置主题 */
helper.setSubject(subject);
/** 设置邮件内容 true为html false为text */
helper.setText(message, isHtml);
/** 发送邮件 */
javaMailSender.send(mimeMessage);
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
账号密码没错,smtp也开启了,防火墙杀毒也关了~ 还是不行 到底哪里错了
吐血了!!!!!!!!!!!!!求大神帮忙看看!!!!!!!