android使用javaemail发送邮件常见错误
一.javax.mail.MessagingException: Unknown SMTP host
该错误主要是由于smtp服务器填写错误导致。但是我在用smtp.163.com时也会报这个错误,不知道是不是163的服务器有问题。
07-19 18:18:57.910: W/System.err(16716): javax.mail.MessagingException: Unknown SMTP host: smtp://smtp.263.net:25;
07-19 18:18:57.910: W/System.err(16716): nested exception is:
07-19 18:18:57.910: W/System.err(16716): java.net.UnknownHostException: Host is unresolved: smtp://smtp.263.net:25
07-19 18:18:57.910: W/System.err(16716): at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1280)
07-19 18:18:57.910: W/System.err(16716): at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
07-19 18:18:57.910: W/System.err(16716): at javax.mail.Service.connect(Service.java:275)
07-19 18:18:57.910: W/System.err(16716): at javax.mail.Service.connect(Service.java:156)
二.java.lang.NoClassDefFoundError: javax.activation.DataHandler
该错误是由于没有导入jar包导致的,提示找不到javax.activation.DataHandler类。需要导入的jar包有:activation.jar,additionnal.jar,commons-email.jar和mail.jar
07-19 18:30:48.940: E/AndroidRuntime(18827): FATAL EXCEPTION: Thread-346
07-19 18:30:48.940: E/AndroidRuntime(18827): Process: com.baic.vds, PID: 18827
07-19 18:30:48.940: E/AndroidRuntime(18827): java.lang.NoClassDefFoundError: javax.activation.DataHandler
07-19 18:30:48.940: E/AndroidRuntime(18827): at javax.mail.internet.MimeBodyPart.setContent(MimeBodyPart.java:678)