这不是SOCKET编程的问题,你需要研究的是SMTP协议吧

解决方案 »

  1.   

    import javax.mail.*;public class EmailAuthenticator extends Authenticator {
        protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication ("user","password" );
        }
      }
    /////
    Properties sessionProp=new Properties();
    //设置认证
    sessionProp.setAttibute("mail.smtp.auth","true");mailSession=Session.getDefaultInstance(sessionProp,new EmailAuthenticator());
    可以用javamail搜索到这些资料。