首页 新闻 会员 周边

关于javamail的smtp.jspinsider.com?

0
悬赏园豆:20 [已关闭问题] 关闭于 2013-08-20 13:48

1.jsp使用javamail:
props.put("mail.smtp.host", "smtp.jspinsider.com");
这样设置邮局服务器有问题没有?


2.是这样的,现在是把邮局服务器设置成某个门户的服务器,发送邮件没有问题;
但提交表单时,可能输入其他的邮箱,所以要设置成任意邮局服务器(网上看到的代码都这样设置smtp.jspinsider.com,我这样改了之后就发不了邮件了~)

代码截取:

 1 //以下一句是对任意的SMTP 邮件服务器均可,并且有了这一句,将不用设置传输协议了
 2 props.put("mail.smtp.host", "smtp.jspinsider.com");
 3  
 4 //Session mailSession = Session.getDefaultInstance(props,null);
 5  
 6 props.put("mail.smtp.auth", "true");
 7 final String user = from;
 8 final String pswd = password;
 9  
10  
11         Session mailSession = Session.getDefaultInstance(props, new Authenticator() {
12             protected PasswordAuthentication getPasswordAuthentication() {
13                 return new PasswordAuthentication(user, pswd);
14             }
15         });
16  
17 /*
18 try {
19         Store store = mailSession.getStore("pop3");
20         store.connect();
21 }catch(javax.mail.AuthenticationFailedException e) {
22     out.println(e.toString());
23 }
24 */
25  
26 //这样将确定接收方的邮件服务器主机,
27 //props.put("mail.host",host);
28 //设置邮件传输协议方式
29 //props.put("mail.transport.protocol","smtp");
30 //获取邮件会话对象
31 //Session mailSession = Session.getDefaultInstance(props,null);
32  
33 mailSession.setDebug(sessionDebug);
34  
35 try{
36 //创建MIME邮件对象
37 Message msg = new MimeMessage(mailSession);
38  
39 //设置收信人
40 InternetAddress[] addressTo = {new InternetAddress("943608716@qq.com")};
41 msg.setRecipients(Message.RecipientType.TO,addressTo);
42 ……
B_yellow的主页 B_yellow | 初学一级 | 园豆:5
提问于:2013-04-15 13:52
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册