小弟最近在研究javamail,遇到了困难,想通过源码进行彻底的学习,那位高手能够给小弟一份啊,小弟感激不尽。

解决方案 »

  1.   

    http://www.soft6.com/tech/13/136235.html
    下载研究一下
      

  2.   

    http://download.csdn.net/down/484908/zhengzhibo
      

  3.   

    邮箱发过来.我给你[email protected] 这是我的要的话M 
      

  4.   

    import java.util.Properties;
    import javax.mail.BodyPart;
    import javax.mail.Message;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;public class Mailsend {  public Mailsend() {
      }  public static int send(String seting_stmp, String user, String password,
                             String mail_from, String mail_to, String title,
                             String content) {
        int i = 0;
        try {      Properties props = new Properties();
          Session sendsession;
          Transport transport;      // 向属性中写入SMTP服务器的地址
          props.put("mail.smtp.host", seting_stmp);      // 设置SMTP服务器需要权限认证
          props.put("mail.smtp.auth", "true");      // 设置输出调试信息
          // PopupAuthenticator auth = new PopupAuthenticator();      sendsession = Session.getInstance(props, null);
          sendsession.setDebug(true);      // 根据Session生成Message对象
          Message message = new MimeMessage(sendsession);
          // 设置发信人地址      message.setFrom(new InternetAddress(mail_from));
          // 设置收信人地址      message.setRecipient(Message.RecipientType.TO, new InternetAddress(mail_to));      // 设置E-mail标题
          message.setSubject(title);      // 设置E-mail发送时间
          //message.setSentDate(new Date());       // 发送html格式的邮件
          // 新建一个存放信件内容的BodyPart对象
          BodyPart mdp = new MimeBodyPart();      // 给BodyPart对象设置内容和格式/编码方式
          mdp.setContent(content, "text/html;charset=gb2312");      Multipart mm = new MimeMultipart();
          // 新建一个MimeMultipart对象用来存放BodyPart对
          // (事实上可以存放多个)
          mm.addBodyPart(mdp);
          // 将BodyPart加入到MimeMultipart对象中(可以加入多个BodyPart)      message.setContent(mm);      // 保存对于E-mail的修改
          message.saveChanges();
          // 根据Session生成Transport对象
          transport = sendsession.getTransport("smtp");
          // 连接到SMTP服务器
          transport.connect(seting_stmp, mail_from, password);
          // 发送E-mail
          transport.sendMessage(message, message.getAllRecipients());
          // 关闭Transport连接
          transport.close();
        }
        catch (Exception e) {
          i = 1;
          // TODO 自动生成 catch 块
          e.printStackTrace();
        }
        return i;
      }}