JSP开发全程实录第四章企业快信添加一般信息和发邮件出去(或带附件的附件名是中文)只要出现中文就乱啊?
发表在JavaWeb图书答疑 2010-07-03
是否精华
版块置顶:
JSP开发全程实录第四章企业快信添加一般信息和发邮件出去(或带附件的附件名是中文)只要出现中文就乱啊?
且当发邮件时带附件的附件名是中文时邮件发送就失败。
报错提示:

文件大小:36322
获取的查询字符串:sendMail
DEBUG: setDebug: JavaMail version 1.3
路径:C:/Program Files/Apache Software Foundation/Tomcat 6.0/temp/??.jpg
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true

DEBUG: SMTPTransport trying to connect to host "smtp.163.com", port 25

DEBUG SMTP RCVD: 220 163.com Anti-spam GT for Coremail System (163com[20090903])

DEBUG: SMTPTransport connected to host "smtp.163.com", port: 25

DEBUG SMTP SENT: EHLO computer
DEBUG SMTP RCVD: 250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFZrBNVUCa0xDrUUUUj
250 8BITMIME

DEBUG SMTP Found extension "PIPELINING", arg ""
DEBUG SMTP Found extension "AUTH", arg "LOGIN PLAIN"
DEBUG SMTP Found extension "AUTH=LOGIN", arg "PLAIN"
DEBUG SMTP Found extension "coremail", arg "1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFZrBNVUCa0xDrUUUUj"
DEBUG SMTP Found extension "8BITMIME", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP SENT: AUTH LOGIN
DEBUG SMTP RCVD: 334 dXNlcm5hbWU6

DEBUG SMTP SENT: Z2FveXVhbnl1ZmFjZUAxNjMuY29t
DEBUG SMTP RCVD: 334 UGFzc3dvcmQ6

DEBUG SMTP SENT: MDA3OTEwZmFjZQ==
DEBUG SMTP RCVD: 235 Authentication successful

DEBUG SMTP: use8bit false
DEBUG SMTP SENT: MAIL FROM:<gaoyuanyuface@163.com>
DEBUG SMTP RCVD: 250 Mail OK

DEBUG SMTP SENT: RCPT TO:<s1505590280@163.com>
DEBUG SMTP RCVD: 250 Mail OK

Verified Addresses
  s1505590280@163.com
DEBUG SMTP SENT: DATA
DEBUG SMTP RCVD: 354 End data with <CR><LF>.<CR><LF>

java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 6.0\temp\??.jpg (文件名、目录名或卷标语法不正确。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at javax.activation.FileDataSource.getInputStream(FileDataSource.java:82)
at javax.activation.DataHandler.writeTo(DataHandler.java:289)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1147)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:668)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:232)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:67)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:868)
at javax.activation.DataHandler.writeTo(DataHandler.java:301)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1147)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1600)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:324)
at com.wgh.dao.SendMailDAO.sendMail(SendMailDAO.java:70)
at com.wgh.action.SendMail.sendMail(SendMail.java:53)
at com.wgh.action.SendMail.execute(SendMail.java:31)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
发送邮件产生的错误:IOException while sending message;
  nested exception is:
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 6.0\temp\??.jpg (文件名、目录名或卷标语法不正确。)
分享到:
精彩评论 1
柠檬草
学分:0 LV1
2010-07-05
沙发
在设置邮件主题前需要将主题字串的字节编码为BASE64格式,并添加编码头,示例代码如下: 
try{
String subject = "中华全国helloworld";
String content = "测试邮件中语言问题.helloworld";
Context ctx = new InitialContext();
if(ctx == null)
throw new Exception("NO Context()");
System.out.println(ctx);


javax.mail.Session mailsession = (javax.mail.Session)ctx.lookup("java:comp/env/mail/session");
System.out.println(mailsession);


Message msg = new MimeMessage(mailsession);


InternetAddress[] toAddrs = InternetAddress.parse("david.li@maxcard.com",false);
msg.setRecipients(Message.RecipientType.TO, toAddrs);
//msg.setSubject("=?GB2312?B?"+Base64.encode(subject.getBytes())+"?=");

//将中文转化为GB2312编码
subject = StringUtil.getString(subject, "GB2312");
subject = new String(Base64.encode((subject).getBytes()));
msg.setSubject("=?GB2312?B?" + subject + "?=");

msg.setFrom(new InternetAddress("david.li@maxcard.com"));
msg.setText(StringUtil.getString(content,"GB2312"));
//
Transport t = mailsession.getTransport("smtp");
t.send(msg);
out.println("成功");
//Transport.send(msg);
}catch(Exception e){
out.println("失败");
System.out.println(e);
}
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照