使用javaMail發郵件時發現一個問題,若是from中含有中文字符,就會報地址錯誤.
com.sun.mail.smtp.SMTPSendFailedException: 501 5.1.7 Syntax error in sender address
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1829)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1368)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:886)
at javax.mail.Transport.send0(Transport.java:191)
at javax.mail.Transport.send(Transport.java:120)
at cn.edu.pdsu.service.mail.send.SendMail.sendMail(SendMail.java:200)
at cn.edu.pdsu.action.user.UserSendMailAction.sendEmail(UserSendMailAction.java:239)
at cn.edu.pdsu.action.user.UserSendMailAction$$FastClassByCGLIB$$8c38168.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at cn.edu.pdsu.utils.LogWriter.doBasicProfiling(LogWriter.java:29)
at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
感謝各位解答,我用了一個取巧的方法,就是前台顯示的是全部地址,傳到後台時進行分割,只處理部分有效信息,如全部地址是"測試"[email protected].則後
台只處理 [email protected] 這個地址,當查看收件箱時,通過 [email protected]來查詢對應的中文名,然後字符串進行拼接,這樣就避免了解決中文亂碼的問題.