Topic: 求教:java Mail程序报错 |
Print this page |
1.求教:java Mail程序报错 | Copy to clipboard |
Posted by: pc Posted on: 2005-01-26 18:53 public void sendmail() throws Exception{ Session session; MimeMessage message; from = "sz_reqly@163.com"; smtpHost = "smtp.163.com"; to = "sz_reqly@163.com"; pwd = "12345"; subject = "subject"; comment = "comment"; System.out.println(smtpHost); System.out.println(id); System.out.println(from); System.out.println(to); Properties props = System.getProperties(); props.put("mail.smtp.host",smtpHost); session = Session.getInstance(props,null); message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setRecipient(Message.RecipientType.TO,new InternetAddress(to)); message.setSubject(subject); message.setText(comment); message.setSentDate(new java.util.Date()); Transport transport = session.getTransport("smtp"); transport.connect(smtpHost,id,pwd); transport.send(message); }//send mail 错误如下: nested exception is: javax.mail.MessagingException: 553 You are not authorized to send mail as >, authentication is required org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800) org.apache.jsp.Internet.email_jsp._jspService(email_jsp.java:76) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) root cause javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: 553 You are not authorized to send mail as >, authentication is required javax.mail.Transport.send0(Transport.java:219) javax.mail.Transport.send(Transport.java:81) pc.Examples.Servlet.internet.EmailSender.sendmail(EmailSender.java:107) org.apache.jsp.Internet.email_jsp._jspService(email_jsp.java:62) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |