mail_host指邮件主机.不需要你的机器上配置什么东西,只要有tcpip协议就可以了.
举过例子,[email protected]是你的邮箱,别人要发信给你,就必须先发到你的邮件主机机上,fun.21cn.com的邮件主机是mta.21cn.com,在NT或2000下可以通过
nslookup -type=mx fun.21cn.com 查到.

解决方案 »

  1.   

    去sun的站点下载这两个文件mail.jar,activation.jar
    用以下的代码就可以发邮件了import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;public class SendMessage {// Collect the necessary information to send a simple message
    // Make sure to replace the values for host, to, and from with
    // valid information.
    // host - must be a valid smtp server that you currently have
    // access to.
    // to - whoever is going to get your email
    // from - whoever you want to be. Just remember that many smtp
    // servers will validate the domain of the from address
    // before allowing the mail to be sent.  private String host;
      private String from;
      private String to;
      private String subject;
      private String messagetext;
      private String transportprotocol;  public SendMessage() {
      }  public void setHost(String shost){
        host = shost;
      }  public void setTo(String sto){
        to = sto;
      }  public void setFrom(String sfrom){
        from = sfrom;
      }  public void setSubject(String ssubject){
        subject = ssubject;
      }  public void setMessagetext(String smessage){
        messagetext = smessage;
      }  public void setTransportprotocol(String stp){
        transportprotocol = stp;
      }  public boolean Send() {
        boolean brt = false;    Properties props = System.getProperties();
        props.put("mail.host", host);
        props.put("mail.transport.protocol", transportprotocol);    Session session = Session.getDefaultInstance(props, null);
        try {
          //Instantiate a new MimeMessage and fill it with the
          //required information.
          Message msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(from));
          InternetAddress[] address = {new InternetAddress(to)};
          msg.setRecipients(Message.RecipientType.TO, address);
          msg.setSubject(subject);
          msg.setSentDate(new Date());
          msg.setText(messagetext);      // Hand the message to the default transport service
          // for delivery.
          Transport.send(msg);
          brt = true;
        }
        catch (MessagingException e) {
          e.printStackTrace();
        }    return brt;  }}
      

  2.   

    怎样用java程序获得一个邮件地址的主机呢?
      

  3.   

    怎样用java程序获得一个邮件地址的主机呢?
      

  4.   

    怎样用java程序获得一个邮件地址的主机呢?
      

  5.   

    你发邮件时候用到的mail.host设置成你自己邮箱所用的主机地址就可以了,可以把它放在一个属性文件里读取会灵活些
      

  6.   

    怎么发邮件的附件啊??,JAVA中有没有这样的函数啊??
      

  7.   

    怎么发邮件的附件啊??,JAVA中有没有这样的函数啊??