关于JAVAMAIL问题,提示说找不到SMTP服务器,可能是我的MAILSERVER错误,下面有注释,请帮忙解决,给分!
public boolean emitMail(HttpServletRequest request, String _content)
{
boolean isSucc = true;
InternetAddress[] address = null;
try
{
request.setCharacterEncoding("GB2312");
}
catch(UnsupportedEncodingException uex)
{
isSucc = false;
System.out.println("request.setCharacterEncoding(GB2312) error");
}
//这下面几句是否有错误
String mailServer = "ecd.163.com";
String from = "jb_china2008@163.com";
String to = "jb_china2004@163.com";
String title = "订报";
String content = _content;
boolean sessionDebug = false;
try
{
java.util.Properties props = System.getProperties();
props.put("mail.host", mailServer);
props.put("mail.transport.protocol", "smtp");
javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance(props,
null);
mailSession.setDebug(sessionDebug);
javax.mail.Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
address = InternetAddress.parse(to, false);
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(title);
msg.setSentDate(new Date());
msg.setText(content);
Transport.send(msg);
System.out.println("邮件已顺利传送");
}
catch(MessagingException e)
{
isSucc = false;
e.printStackTrace();
}
return isSucc;
}