由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 什么错了, Invalid protocol: null
相关主题
string operator +spring真是大包大揽啊
Pattern matching计算围棋棋盘合法图案的源代码
[合集] c++的题问一个奇怪的tomcat+svg问题 (转载)
数据类型判断Java是不是主要用于开发Web的?
关于inserter转行中,努力中 (转载)
deque的pointer和reference是怎么回事?请教官网下载的tomcat怎么不能安装呢
java string stream新手求助 ARR里添加Tomcat的问题 (转载)
谈一下王垠当年制造出的一个大麻烦主力程序员离职后怎么办?
相关话题的讨论汇总
话题: string话题: message话题: session话题: invalid话题: address
进入Programming版参与讨论
1 (共1页)
c*****a
发帖数: 808
1
在用apache tomcat+jsp
ERROR: Unable to send email. Check Tomcat logs for details.
ERROR MESSAGE: Invalid protocol: null
public static void sendMail(String to, String from,
String subject, String body, boolean bodyIsHTML)
throws MessagingException
{
String mailhost = "smtp.gmail.com";
// 1 - get a mail session
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");
Session session = Session.getDefaultInstance(props);
session.setDebug(true);
// 2 - create a message
Message message = new MimeMessage(session);
message.setSubject(subject);
if (bodyIsHTML)
message.setContent(body, "text/html");
else
message.setText(body);
// 3 - address the message
Address fromAddress = new InternetAddress(from);
Address toAddress = new InternetAddress(to);
message.setFrom(fromAddress);
message.setRecipient(Message.RecipientType.TO, toAddress);
// 4 - send the message
Transport transport = session.getTransport();
transport.connect("x**[email protected]", "xxxx");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
c*****a
发帖数: 808
2
tomcat logs
Aug 19, 2012 4:28:10 PM org.apache.catalina.core.ApplicationContext log
INFO: PWrecoverServlet: Unable to send email.
Here is the email you tried to send:
=====================================
TO: X***[email protected]
FROM: e********[email protected]
SUBJECT: PassWord Recovery
Dear XXX,
Your password is XXXX
1 (共1页)
进入Programming版参与讨论
相关主题
主力程序员离职后怎么办?关于inserter
大家用哪个免费的网站,自己把code upload上去?deque的pointer和reference是怎么回事?
请问一下怎么提高实际的框架和架构能力呢?java string stream
前端又为什么不用java呢?谈一下王垠当年制造出的一个大麻烦
string operator +spring真是大包大揽啊
Pattern matching计算围棋棋盘合法图案的源代码
[合集] c++的题问一个奇怪的tomcat+svg问题 (转载)
数据类型判断Java是不是主要用于开发Web的?
相关话题的讨论汇总
话题: string话题: message话题: session话题: invalid话题: address