JavaMail 在服务器2003上发送不了邮件

private void sendMail(Hashtable gz){
        String m_strContent = "<p><table><tr><td>Hello javaMail and test example!</td></tr></table></p>";
        Properties provs = new Properties();
        Authenticator auth = new MyAuthenticator(username,password);
        provs.put("mail.smtp.host", host);
        provs.put("mail.smtp.auth", "true");
        provs.put("mail.transport.protocol", "smtp");
        provs.put("mail.smtp.port", "25");
        Session session = Session.getDefaultInstance(provs,null);
        session.setDebug(true);
        MimeMessage message = new MimeMessage(session);
        try {
            message.setSubject("test javaMail");//jtfsubject.getText()
            message.setSentDate(new Date());
            message.setContext("Test Mail","text/html");

        } catch (IOException ex) {
            Logger.getLogger(TestSendMail.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MessagingException ex) {
            Logger.getLogger(TestSendMail.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            Address toAddress = new InternetAddress(mailAddress);//yuping159@gmail.com
            Address fromAddress = new InternetAddress("87523774@qq.com");
            Address reply = new InternetAddress("56545465@qq.com");
            message.setReplyTo(new Address[]{reply});
    
            message.setFrom(fromAddress);
            message.setRecipients(RecipientType.TO, new Address[]{toAddress});
            message.saveChanges(); // implicit with send()
           Transport transport = session.getTransport("smtp");
            transport.connect(host, username, password);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();
        }catch(AuthenticationFailedException e){
            JOptionPane.showMessageDialog(null, "密码错误");
        } catch (AddressException ex) {
            Logger.getLogger(TestSendMail.class.getName()).log(Level.SEVERE, null, ex);
        } catch(SMTPSendFailedException e){
            JOptionPane.showMessageDialog(null, "邮件发送失败");
        } catch (MessagingException ex) {
            Logger.getLogger(TestSendMail.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

 

 

 

以上代码是使用javaMail发送邮件的,在本地测试通过,可以发送邮件,但是到2003服务器上就不行了,本人不清楚,这个smtp服务一定要开通吗,或者说和2003系统有哪些问题?2003系统没有打sp2补丁包,IIS服务中没有选择安装smtp Service这服务。

 

本人做的测试是,在本人的机器xp上,即使把smtp Service 服务部打钩,重新配置IIS,还是可以发送smtp邮件.

 

请问大侠,请提供思路,问题有可能出现在哪里?

本人QQ:87523774;

万分感谢!!!!!!!

 

补充说明,和代码没有什么联系,应该重smtp服务的环境考虑。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值