用javamail做邮件发送程序,我用的sina邮箱作为邮件服务器,发送邮件有时成功有时失败`` 这是我代码的问题`还是这样发邮件本身就只有一定成功率?
   有人说是邮件服务器的问题,我用的是普通注册邮箱,如果换上公司邮箱会不会好点?
    平时大家是用什么邮件服务器的?      如果大家认为是代码问题我再把代码发上来··应为我感觉代码好像没什么问题··o(∩_∩)o...

解决方案 »

  1.   

    有可能是sina的服务器问题,
    如果公司有自己的emailServer,smtpHost 那就用公司的啊!
    我就用的是公司的...不会有你的问题 >_<
    不过还是想看一下你的代码...
      

  2.   

    try{
    //从html表单中获取邮件信息
    String tto=sendMeailForm.getTo();
    String ttitle=sendMeailForm.getTitle();
    String tcontent=sendMeailForm.getContent();
                System.out.println(tto+"///"+ttitle+"///"+tcontent);

    Properties props=new Properties
    props.put("mail.smtp.host","smtp.sina.com");//存储发送邮件服务器的信息
    props.put("mail.smtp.auth","true");//同时通过验证
    Session s=Session.getInstance(props);//根据属性新建一个邮件会话
    s.setDebug(true); MimeMessage message=new MimeMessage(s);//由邮件会话新建一个消息对象 //设置邮件
    InternetAddress from=new InternetAddress("[email protected]");
    message.setFrom(from);//设置发件人
    InternetAddress to=new InternetAddress(tto);
    message.setRecipient(Message.RecipientType.TO,to);//设置收件人,并设置其接收类型为TO
    message.setSubject(ttitle);//设置主题
    message.setText(tcontent);//设置信件内容
    message.setSentDate(new Date());//设置发信时间 //发送邮件
    message.saveChanges();//存储邮件信息
    Transport transport=s.getTransport("smtp");
    transport.connect("smtp.sina.com","huacan_fly","lxf2628");//以smtp方式登录邮箱
    transport.sendMessage(message,message.getAllRecipients());//发送邮件,其中第二个参数是所有
    //已设好的收件人地址
    transport.close();
    }catch(MessagingException e){
    System.out.println(e.toString());
      }
      

  3.   

    给你个邮件安全认证方法试试
    public static class PopupAuthenticator extends Authenticator { String username = null; String password = null; public PopupAuthenticator() {
    } public PasswordAuthentication performCheck(String user, String pass) {
    username = user;
    password = pass;
    return getPasswordAuthentication();
    } protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(username, password);
    }
    }然后调用方法
    PopupAuthenticator popA = new PopupAuthenticator();// 邮件安全认证。
    PasswordAuthentication pop = popA.performCheck(username, password); // 填写用户名及密码
    session = Session.getInstance(properties, popA);