当前位置: 代码迷 >> J2EE >> javax.mail发送邮件时收件人地址报错
  详细解决方案

javax.mail发送邮件时收件人地址报错

热度:375   发布时间:2016-04-17 23:52:30.0
javax.mail发送邮件时收件人地址报错 求高手指教
求高手指教 这个错误怎么改啊?
代码如下:              String content = code ;
     java.util.Properties props = System.getProperties();
     props.put("mail.host", mailSever);
     props.put("mail.transport.protocol", "smtp");
     props.put("mail.smtp.auth","true");
     MyAuth auth = new MyAuth(userName, passwd);
     auth.getPasswordAuthentication();
     System.out.println("auth==="+auth);
     javax.mail.Session mailSession = javax.mail.Session.getInstance(props, auth);
     mailSession.setDebug(true);
     MimeMessage msg = new MimeMessage(mailSession);
     msg.setFrom(new InternetAddress( from ));
     InternetAddress to_mail = new InternetAddress("asdasd@163.com,asddsa@163.com");
     msg.setRecipient(MimeMessage.RecipientType.TO,to_mail);
     msg.setSubject(subject);
     msg.setRecipients(MimeMessage.RecipientType.CC, this.cc );
     msg.setSentDate(new java.util.Date());
     msg.setText(content);
    
     Transport transport=mailSession.getTransport("smtp");
        //连接SMTP服务器
        transport.connect(mailSever, userName, passwd);
        //发送邮件 
        //Transport.send(message,message.getAllRecipients());
        transport.sendMessage(msg,msg.getAllRecipients());
        transport.close();
     //Transport.send(msg);
     System.out.println(" Success !");  


DEBUG: setDebug: JavaMail version 1.4.2
javax.mail.internet.AddressException: Illegal address in string ``asdasd@163.com,asddsa@163.com''
at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:110)
at cn.com.softvan.eos.bizlet.p17.SendMail.send3(SendMail.java:252)
at cn.com.softvan.eos.bizlet.p17.SendEMail.SendMailToSysAndcc(SendEMail.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.primeton.tp.core.bizservice.state.MethodBizState.invoke(MethodBizState.java:74)
at com.primeton.tp.core.bizservice.ProcessRunner.implement(ProcessRunner.java:135)
at com.primeton.tp.core.bizservice.state.SubProcessBizState.invoke(SubProcessBizState.java:156)
at com.primeton.tp.core.bizservice.ProcessRunner.implement(ProcessRunner.java:135)
at com.primeton.tp.core.bizservice.state.SubProcessBizState.invoke(SubProcessBizState.java:156)
at com.primeton.tp.core.bizservice.ProcessRunner.implement(ProcessRunner.java:135)
at com.primeton.tp.core.bizservice.ProcessCaller.implement_noEJB(ProcessCaller.java:193)
at com.primeton.tp.core.bizservice.ProcessCaller.implement(ProcessCaller.java:87)
at org.apache.jsp.internet.debug.bizlogicDebugger_jsp._jspService(bizlogicDebugger_jsp.java:62)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
  相关解决方案