首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

javamail发送邮件提示404异常?高分请问

2012-01-22 
javamail发送邮件提示404错误?高分请教用javamail写了一个发送邮件的程序,但是发送后提示404错误,不知道怎

javamail发送邮件提示404错误?高分请教
用javamail写了一个发送邮件的程序,但是发送后提示404错误,不知道怎么回事。向高手请教。
        页面代码:
<%@   page   language= "java "   contentType= "text/html;   charset=gb2312 "
  pageEncoding= "gb2312 "%>
<%@   page   import= "javax.activation.* "%>
<%@   page   import= "javax.mail.internet.* "%>
<%@   page   import= "java.util.* "%>
<%@   page   import= "javax.mail.* "%>

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">

<%
        class   MyAuthenticator
            extends   javax.mail.Authenticator   {
        private   String   strUser;
        private   String   strPwd;
        public   MyAuthenticator(String   user,   String   password)   {
            this.strUser   =   user;
            this.strPwd   =   password;
        }

        protected   PasswordAuthentication   getPasswordAuthentication()   {
            return   new   PasswordAuthentication(strUser,   strPwd);
        }
    }
%>

  <%        
 
      String   subject   =   request.getParameter( "title ");
      String   subtext   =   request.getParameter( "content ");
     
      if(subject!=null   &&   !subject.equals( " ")   &&   subtext!=null   &&   !subtext.equals( " "))
      {
      try   {

        Properties   props   =   new   Properties();
        props.put( "mail.smtp.host ",   "smtp.163.com ");
        props.put( "mail.smtp.auth ", "true ");

MyAuthenticator   myauth   =   new   MyAuthenticator( "username ",   "password ");
Session   sessions   =   Session.getDefaultInstance(props,   myauth);

        MimeMessage   newMessage   =   new   MimeMessage(sessions);
        newMessage.setFrom(new   InternetAddress(
        "yundazyx@163.com "));

        newMessage.addRecipient(Message.RecipientType.TO,
        new   InternetAddress( "yundazyx@163.com "));

        newMessage.setSubject(subject);
        newMessage.setSentDate(new   Date());
        newMessage.setText(subtext);

newMessage.saveChanges();
      Transport   transport   =   sessions.getTransport( "smtp ");
      transport.connect( "smtp.163.com ",   "username ",   "password ");
        transport.sendMessage(newMessage,   newMessage.getAllRecipients());


        transport.close();

%>
<p> send   mail   success <p>
<%
      }

      catch   (MessagingException   m)

      {
        out.println(m.toString());

      }
      }
  %>

结果提示的错误是:
Error   404--Not   Found  
From   RFC   2068   Hypertext   Transfer   Protocol   --   HTTP/1.1:
10.4.5   404   Not   Found
The   server   has   not   found   anything   matching   the   Request-URI.   No   indication   is   given   of   whether   the   condition   is   temporary   or   permanent.

If   the   server   does   not   wish   to   make   this   information   available   to   the   client,   the   status   code   403   (Forbidden)   can   be   used   instead.   The   410   (Gone)   status   code   SHOULD   be   used   if   the   server   knows,   through   some   internally   configurable   mechanism,   that   an   old   resource   is   permanently   unavailable   and   has   no   forwarding   address.


[解决办法]
一个月还没人解决 啊?
[解决办法]
发送后提示404错误

表示你找不到你发送的资源

你检查了存在这个吗


[解决办法]
应该是你上一个页面的错误。
[解决办法]
分两步分析把,第一部,将发送信息放到最简单,看能否发送成功。
另外,将你获取的HTML部分程序看一下,是否能正常获取

热点排行