Exception in thread “main” java.lang.NullPointerException
at javax.mail.internet.InternetAddress.lengthOfFirstSegment(InternetAddress.java:455)
at javax.mail.internet.InternetAddress.toString(InternetAddress.java:438)
at javax.mail.internet.InternetAddress.toString(InternetAddress.java:402)
at javax.mail.internet.MimeMessage.setAddressHeader(MimeMessage.java:686)
at javax.mail.internet.MimeMessage.setRecipients(MimeMessage.java:565)
at javax.mail.Message.setRecipient(Message.java:353)
at com.dianzhi.util.SimpleMailSender.sendTextMail(SimpleMailSender.java:39)
at com.dianzhi.util.Test.main(Test.java:20)
package com.dianzhi.util;
public class Test {
public static void main(String[] args){
//这个类主要是设置邮件
MailSenderInfo mailInfo = new MailSenderInfo();
mailInfo.setMailServerHost(“smtp.163.com”);
mailInfo.setMailServerPort(“25”);
mailInfo.setValidate(true);
mailInfo.setUserName(“wangbing_888wang@163.com”);
mailInfo.setPassword(“**”);//您的邮箱密码
mailInfo.setFromAddress(“wangbing_888wang@163.com”);
mailInfo.setToAddress(“879697852@qq.com”);
mailInfo.setSubject(“中国桂花网”);
mailInfo.setContent(“你好”);
mailInfo.setAttachFileNames(“ss”);
//这个类主要来发送邮件
SimpleMailSender sms = new SimpleMailSender();
sms.sendTextMail(mailInfo);//发送文体格式
//sms.sendHtmlMail(mailInfo);//发送html格式
}
}