我老板要我做个邮箱~~
  我对这个一点都不了解  希望大家给点资料
  我现在只会java  和vb  不知道能不能做的出来啊~
  我公司是希望有个邮箱向网站注册会员发送一些通知之类的
  希望大家能多给点意见~
  网站的会员大概有几W左右   
   
  希望大家多多帮帮我 啊
   最好能给点资料   结贴时再加100积分 
   

解决方案 »

  1.   

    这里有做好的,有注释,你自己看吧,
    http://blog.csdn.net/rascalboy520/archive/2008/06/24/2581616.aspx
      

  2.   

    推荐使用apache james,很简单的java邮件服务器。
    如果只要发送邮件,直接用javamail就行。
      

  3.   

    我框架内的邮件发送代码,直接可以用的,楼主把该该的地方改一下,比如邮件服务器啊:
    两个类:
    MailBean 和 SendMailOnTime
    需要jar组件:
    activation.jar
    mail.jar
    log4j.jar代码如下:/*
     * Created on 2005-9-7
     *
     * TODO To change the template for this generated file go to
     * Window - Preferences - Java - Code Style - Code Templates
     * 
     * Update on 2008-8-14
     */
    package javaMail;import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;import org.apache.log4j.Logger;/**
     * @author panshengti 类功能:处理意见反馈邮件发送 调用jar:activation.jar、mail.jar
     */public class MailBean {

    public static Logger log=null;
    static{
    log = Logger.getLogger(MailBean.class);
    }

    // smtpHost发件人所用到的smtp服务器
    String smtpHost = "smtp.163.com";
    // from发件人邮箱
    String from = "[email protected]";
    // to收件人邮箱
    String to = "[email protected]";
    // subject邮件标题
    String subject = "receive a mail from [email protected]";
    // theMessage邮件内容
    StringBuffer theMessage = new StringBuffer(); /**
     * 固定的给[email protected],[email protected]发送邮件
     * create date:2008-8-15
     * author:Administrator
     *
     * @param smtpHost
     * @param from
     * @param subject
     * @param messageText
     * @throws MessagingException
     */
    public void sendMessage(String smtpHost, String from,
    String subject, String messageText) throws MessagingException {
    SmtpAuth sa = new SmtpAuth();
    sa.getuserinfo("d-ear", "123abc");
    java.util.Properties props = new java.util.Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.host", smtpHost);
    System.out.println("Constructing message- from=" + from + " to=" + to);
    InternetAddress fromAddress = new InternetAddress(from);
    InternetAddress[] toAddresss = new InternetAddress[2];
    toAddresss[0] = new InternetAddress("[email protected]");
    toAddresss[1] = new InternetAddress("[email protected]");
    int i = 0;
    while (i < toAddresss.length) {
    Session mailSession = Session.getDefaultInstance(props, sa);
    MimeMessage testMessage = new MimeMessage(mailSession);
    testMessage.setFrom(fromAddress);
    testMessage.addRecipient(javax.mail.Message.RecipientType.TO,
    toAddresss[i]);
    testMessage.setSentDate(new java.util.Date());
    testMessage.setSubject(subject);
    testMessage.setText(messageText); Transport.send(testMessage);
    System.out.println("A mail have been sent!");
    i++;
    }
    } /*
     * 由163服务器向目的邮箱发送邮件
     * 邮件发送处理 @param stmHost,from,to,subject,messageText
     */ public void sendMessage(String smtpHost, String from, String to,
    String subject, String messageText) throws MessagingException {
    SmtpAuth sa = new SmtpAuth();
    sa.getuserinfo("d-ear", "123abc");
    java.util.Properties props = new java.util.Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.host", smtpHost);
    System.out.println("Constructing message- from=" + from + " to=" + to);
    InternetAddress fromAddress = new InternetAddress(from);
    InternetAddress toAddresss = new InternetAddress(to);


    Session mailSession = Session.getDefaultInstance(props, sa);
    MimeMessage testMessage = new MimeMessage(mailSession);
    testMessage.setFrom(fromAddress);
    testMessage.addRecipient(javax.mail.Message.RecipientType.TO,
    toAddresss);
    testMessage.setSentDate(new java.util.Date());
    testMessage.setSubject(subject);
    testMessage.setText(messageText); Transport.send(testMessage);
    System.out.println("A mail have been sent to "+ to);

    } /**
     * 功能:群发功能,把所有的目的邮箱作为一个数组参数传入
     * create date:2008-8-15
     * author:Administrator
     *
     * @param smtpHost
     * @param from
     * @param to 目的邮箱数组
     * @param subject
     * @param messageText
     * @throws MessagingException
     */
    public void sendMessage(String smtpHost, String from, String[] to,
    String subject, String messageText) throws MessagingException {
    SmtpAuth sa = new SmtpAuth();
    sa.getuserinfo("d-ear", "123abc");
    java.util.Properties props = new java.util.Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.host", smtpHost);
    System.out.println("Constructing message- from=" + from + " to=" + to);
    InternetAddress fromAddress = new InternetAddress(from);

    InternetAddress[] toAddresss = new InternetAddress[to.length];
    for(int len=0;len<to.length;len++){
    toAddresss[0] = new InternetAddress(to[len]);
    }

    int i = 0;
    while (i < toAddresss.length) {
    Session mailSession = Session.getDefaultInstance(props, sa);
    MimeMessage testMessage = new MimeMessage(mailSession);
    testMessage.setFrom(fromAddress);
    testMessage.addRecipient(javax.mail.Message.RecipientType.TO,
    toAddresss[i]);
    testMessage.setSentDate(new java.util.Date());
    testMessage.setSubject(subject);
    testMessage.setText(messageText); Transport.send(testMessage);
    System.out.println("A mail have been sent to "+to[i]);
    i++;
    }
    }
    /*
     * 邮件用户名和密码认证
     */
    static class SmtpAuth extends javax.mail.Authenticator {
    private String user, password; public void getuserinfo(String getuser, String getpassword) {
    user = getuser;
    password = getpassword;
    } protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
    return new javax.mail.PasswordAuthentication(user, password);
    }
    }}package javaMail;import javax.mail.MessagingException;import org.apache.log4j.Logger;public class SendMailOnTime { public static Logger log = null;
    static {
    log = Logger.getLogger(SendMailOnTime.class);
    } /**
     * @param args
     */
    public static void sendMail(String str) { MailBean mail = new MailBean();
    try {
    mail.sendMessage("smtp.163.com", "[email protected]",
    "rent information", str);
    } catch (MessagingException e) {
    System.out.println("mail send error !");
    log.debug("mail send error !" + e.getMessage());
    e.printStackTrace();
    }
    System.out.println("Mail have been sended .");
    } /**
     * 给一个指定邮箱发送指定的邮件内容 create date:2008-8-15 author:Administrator
     * 
     * @param str
     */
    public static void sendMail(String toMail, String content) { MailBean mail = new MailBean();
    try {
    mail.sendMessage("smtp.163.com", "[email protected]", toMail,
    "spider information", content);
    } catch (MessagingException e) {
    System.out.println("mail send error !");
    log.debug("mail send error !" + e.getMessage());
    e.printStackTrace();
    }
    System.out.println("Mail have been sended .");
    } /**
     * 指定目的邮箱数组进行群发 create date:2008-8-15 author:Administrator
     * 
     * @param toMail
     * @param content
     */
    public static void sendMail(String[] toMail, String content) { MailBean mail = new MailBean();
    try {
    mail.sendMessage("smtp.163.com", "[email protected]", toMail,
    "spider information", content);
    } catch (MessagingException e) {
    System.out.println("mail send error !");
    log.debug("mail send error !" + e.getMessage());
    e.printStackTrace();
    }
    System.out.println("Mail have been sended .");
    }}
      

  4.   

    强烈建议下载张孝祥老师的Java邮件开发的视频,看完会让你非常清楚的
      

  5.   

    import   java.io.*;   
      import   java.net.Socket;   
      import   java.util.*;   
        
        
      public   class   SendMail{   
      private   Socket   mailSocket;   
              private   BufferedReader   recv;   
              private   PrintWriter   send;   
              private   String   from;   
              private   String   to;   
              private   String   domain;   
              private   Vector   x_set;   
              private   Vector   body;   
              private   Vector   attach;   
                
              private   String   DELIMETER;   
              private   String   SEPARATOR;   
                
              public   SendMail(){   
                      DELIMETER   =   "";   
                      SEPARATOR   =   "";   
                      mailSocket   =   null;   
                      recv   =   null;   
                      send   =   null;   
                      from   =   "";   
                      to   =   "";   
                      domain   =   "";   
                      x_set   =   new   Vector();   
                      body   =   new   Vector();   
                      attach   =   new   Vector();   
                      //DELIMETER   =   getId();   
                      //SEPARATOR   =   System.getProperty("file.separator");   
              }   
              
      public   int   open(String   serverName,   int   port)   
      {   
      try{   
      mailSocket   =   new   Socket(serverName,   port);   
      send   =   new   PrintWriter(mailSocket.getOutputStream(),   true);   
      recv   =   new   BufferedReader(new   InputStreamReader(mailSocket.getInputStream()));   
      String   s1   =   recv.readLine();   
      char   c   =   s1.charAt(0);   
      if((c   ==   '4')   |   (c   ==   '5'))   
      return   0;   
      }   
        catch(Exception   e){   
        return   0;   
        }   
        return   1;   
      }   
        
      public   int   transmit(){   
        boolean   flag   =   true;   
        System.out.println("enter   into   transmit");   
        //发送HELO   命令   
      if(domain.length()   !=   0){   
      int   i   =   sendString("HELO   "   +   domain);   
      if(i   !=   1){   
      System.out.println(domain);   
          return   0;   
        }   
      //System.out.println("send   mail   from   "+from);   
        //发送MAIL   FROM   命令(发件人)   
        if(from.length()   !=   0){   
          int   j   =   sendString("MAIL   FROM:"   +   from);   
          if(j   !=   1)   
          return   0;   
        }   
        //System.out.println("send   mail   to   "+to);   
        //发送RCPT   TO   命令(收件人)   
        if(to.length()   !=   0){   
          int   k   =   sendString("RCPT   TO:"   +   to);   
          if(k   !=   1)   
          return   0;   
        }   
        //发送邮件正文(DATA   命令)   
        if(sendString("DATA")   !=   1)   
        return   0;   
            
        x_set.add("SUBJECT");x_set.add("性能数据问题");   
        //发送邮件头信息   
        //System.out.println("send   mail   header");   
        for(int   l   =   0;   l   <   x_set.size();   l   +=   2){   
          String   s   =   (String)x_set.elementAt(l);   
          send.println(s   +   ":   "   +   x_set.elementAt(l   +   1));   
        }   
        send.println("\r\n");   
        send.println("你好\r\n");     
        //发送时间及相关内容格式说明   
        if(x_set.indexOf("Date")   <   0) send.println("Date:   "   +   (new   Date()).toString());   
          
          
      }   
      return   0;   
      }   
      //返回1表示命令被拒绝执行,返回0表示命令被接受   
      private   int   sendString(String   s){   
        String   s1   =   "";   
        try{   
        System.out.println("send   content   is   "+s);   
          send.println(s);   
          s1   =   recv.readLine();   
          System.out.println("rec   conetnt   is   "+s1);   
        }   
        catch(Exception   e){   
          System.out.print(s1);   
          return   0;   
        }   
        if(s1.length()   ==   0)     
        return   0;   
        char   c   =   s1.charAt(0);   
        return   !((c   ==   '4')   |   (c   ==   '5'))   ?   1   :   0;   
          
        }   
      public   int   close(){   
        int   i   =   0;   
        //消息内容结束标志   
        sendString(".");       
        try{   
          i   +=   sendString("QUIT");   
          mailSocket.close();   
        }   
        catch(Exception   e){   
          return   0;   
        }   
        return   i   ==   0   ?   1   :   0;   
      }   
      public   static   void   main(String   []   argv)   
      {   
      SendMail   m_send   =   new   SendMail();   
      m_send.to   =   "mail   address";//收件人的地址   
      int   ret   =   m_send.open("192.168.1.80",25);   
      System.out.println("return   from   open:"+ret);   
      m_send.from   =   "mail   address";   
      m_send.domain   =   "domain";   
        
      ret   =   m_send.transmit();   
      ret   =   m_send.close();   
      }   
      }