问题描述
- 关于android里面发邮件的问题,下面是我运行时候的log,请各位帮我看一下。
- 04-07 14:06:05.294: I/System.out(2970): DEBUG: JavaMail version 1.4.1
04-07 14:06:05.294: I/System.out(2970): DEBUG: not loading file: /system/lib/javamail.providers
04-07 14:06:05.298: I/System.out(2970): DEBUG: java.io.FileNotFoundException: /system/lib/javamail.providers: open failed: ENOENT (No such file or directory)
04-07 14:06:05.298: I/System.out(2970): DEBUG: !anyLoaded
04-07 14:06:05.298: I/System.out(2970): DEBUG: not loading resource: /META-INF/javamail.providers
04-07 14:06:05.298: I/System.out(2970): DEBUG: not loading resource: /META-INF/javamail.default.providers
04-07 14:06:05.298: I/System.out(2970): DEBUG: failed to load any providers using defaults
04-07 14:06:05.298: I/System.out(2970): DEBUG: Tables of loaded providers
04-07 14:06:05.298: I/System.out(2970): DEBUG: Providers Listed By Class Name: {com.sun.mail.imap.IMAPStore=javax.mail.Provider[STOREimapcom.sun.mail.imap.IMAPStoreSun Microsystems Inc.1.4.1] com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORTsmtpcom.sun.mail.smtp.SMTPTransportSun Microsystems Inc.1.4.1] com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STOREpop3scom.sun.mail.pop3.POP3SSLStoreSun Microsystems Inc.1.4.1] com.sun.mail.pop3.POP3Store=javax.mail.Provider[STOREpop3com.sun.mail.pop3.POP3StoreSun Microsystems Inc.1.4.1] com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORTsmtpscom.sun.mail.smtp.SMTPSSLTransportSun Microsystems Inc.1.4.1] com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STOREimapscom.sun.mail.imap.IMAPSSLStoreSun Microsystems Inc.1.4.1]}
04-07 14:06:05.298: I/System.out(2970): DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STOREimapscom.sun.mail.imap.IMAPSSLStoreSun Microsystems Inc.1.4.1] smtp=javax.mail.Provider[TRANSPORTsmtpcom.sun.mail.smtp.SMTPTransportSun Microsystems Inc.1.4.1] pop3=javax.mail.Provider[STOREpop3com.sun.mail.pop3.POP3StoreSun Microsystems Inc.1.4.1] pop3s=javax.mail.Provider[STOREpop3scom.sun.mail.pop3.POP3SSLStoreSun Microsystems Inc.1.4.1] imap=javax.mail.Provider[STOREimapcom.sun.mail.imap.IMAPStoreSun Microsystems Inc.1.4.1] smtps=javax.mail.Provider[TRANSPORTsmtpscom.sun.mail.smtp.SMTPSSLTransportSun Microsystems Inc.1.4.1]}
04-07 14:06:05.298: I/System.out(2970): DEBUG: not loading resource: /META-INF/javamail.default.address.map
04-07 14:06:05.298: I/System.out(2970): DEBUG: !anyLoaded
04-07 14:06:05.302: I/System.out(2970): DEBUG: not loading resource: /META-INF/javamail.address.map
04-07 14:06:05.302: I/System.out(2970): DEBUG: not loading file: /system/lib/javamail.address.map
04-07 14:06:05.302: I/System.out(2970): DEBUG: java.io.FileNotFoundException: /system/lib/javamail.address.map: open failed: ENOENT (No such file or directory)
04-07 14:06:05.302: I/System.out(2970): DEBUG: failed to load address map using defaults
04-07 14:06:05.326: D/dalvikvm(2970): GC_CONCURRENT freed 195K 8% free 8162K/8839K paused 11ms+0ms total 17ms
04-07 14:06:05.350: I/System.out(2970): DEBUG: getProvider() returning javax.mail.Provider[TRANSPORTsmtpcom.sun.mail.smtp.SMTPTransportSun Microsystems Inc.1.4.1]
04-07 14:06:05.350: I/System.out(2970): DEBUG SMTP: useEhlo true useAuth true
04-07 14:06:05.350: I/System.out(2970): DEBUG SMTP: trying to connect to host ""smtp.qq.com"" port 25 isSSL false
04-07 14:06:05.458: I/System.out(2970): 220 smtp.qq.com Esmtp QQ Mail Server04-07 14:06:05.458: I/System.out(2970): DEBUG SMTP: connected to host ""smtp.qq.com"" port: 25
04-07 14:06:05.458: I/System.out(2970): EHLO localhost04-07 14:06:05.494: I/System.out(2970): 250-smtp.qq.com
04-07 14:06:05.494: I/System.out(2970): 250-PIPELINING
04-07 14:06:05.494: I/System.out(2970): 250-SIZE 52428800
04-07 14:06:05.494: I/System.out(2970): 250-STARTTLS
04-07 14:06:05.494: I/System.out(2970): 250-AUTH LOGIN PLAIN
04-07 14:06:05.494: I/System.out(2970): 250-AUTH=LOGIN
04-07 14:06:05.494: I/System.out(2970): 250-MAILCOMPRESS
04-07 14:06:05.494: I/System.out(2970): 250 8BITMIME
04-07 14:06:05.498: I/System.out(2970): DEBUG SMTP: Found extension ""PIPELINING"" arg """"
04-07 14:06:05.498: I/System.out(2970): DEBUG SMTP: Found extension ""SIZE"" arg ""52428800""
04-07 14:06:05.498: I/System.out(2970): DEBUG SMTP: Found extension ""STARTTLS"" arg """"
04-07 14:06:05.498: I/System.out(2970): DEBUG SMTP: Found extension ""AUTH"" arg ""LOGIN PLAIN""
04-07 14:06:05.502: I/System.out(2970): DEBUG SMTP: Found extension ""AUTH=LOGIN"" arg """"
04-07 14:06:05.502: I/System.out(2970): DEBUG SMTP: Found extension ""MAILCOMPRESS"" arg """"
04-07 14:06:05.502: I/System.out(2970): DEBUG SMTP: Found extension ""8BITMIME"" arg """"
04-07 14:06:05.502: I/System.out(2970): DEBUG SMTP: Attempt to authenticate
04-07 14:06:05.502: I/System.out(2970): AUTH LOGIN04-07 14:06:05.542: I/System.out(2970): 334 VXNlcm5hbWU6
04-07 14:06:05.542: I/System.out(2970): MTQ0Njc5MDY4MUBxcS5jb20g
04-07 14:06:05.590: I/System.out(2970): DEBUG SMTP: EOF: [EOF]
04-07 14:06:05.590: I/System.out(2970): DEBUG SMTP: useEhlo true useAuth true
04-07 14:06:05.590: I/System.out(2970): DEBUG SMTP: trying to connect to host ""smtp.qq.com"" port 25 isSSL false
04-07 14:06:05.666: I/System.out(2970): 220 smtp.qq.com Esmtp QQ Mail Server04-07 14:06:05.666: I/System.out(2970): DEBUG SMTP: connected to host ""smtp.qq.com"" port: 25
04-07 14:06:05.666: I/System.out(2970): EHLO localhost04-07 14:06:05.702: I/System.out(2970): 250-smtp.qq.com
04-07 14:06:05.702: I/System.out(2970): 250-PIPELINING
04-07 14:06:05.706: I/System.out(2970): 250-SIZE 52428800
04-07 14:06:05.706: I/System.out(2970): 250-STARTTLS
04-07 14:06:05.706: I/System.out(2970): 250-AUTH LOGIN PLAIN
04-07 14:06:05.706: I/System.out(2970): 250-AUTH=LOGIN
04-07 14:06:05.706: I/System.out(2970): 250-MAILCOMPRESS
04-07 14:06:05.706: I/System.out(2970): 250 8BITMIME
04-07 14:06:05.706: I/System.out(2970): DEBUG SMTP: Found extension ""PIPELINING"" arg """"
04-07 14:06:05.706: I/System.out(2970): DEBUG SMTP: Found extension ""SIZE"" arg ""52428800""
04-07 14:06:05.706: I/System.out(2970): DEBUG SMTP: Found extension ""STARTTLS"" arg """"
04-07 14:06:05.710: I/System.out(2970): DEBUG SMTP: Found extension ""AUTH"" arg ""LOGIN PLAIN""
04-07 14:06:05.710: I/System.out(2970): DEBUG SMTP: Found extension ""AUTH=LOGIN"" arg """"
04-07 14:06:05.710: I/System.out(2970): DEBUG SMTP: Found extension ""MAILCOMPRESS"" arg """"
04-07 14:06:05.710: I/System.out(2970): DEBUG SMTP: Found extension ""8BITMIME"" arg """"
04-07 14:06:05.710: I/System.out(2970): DEBUG SMTP: Attempt to authenticate
04-07 14:06:05.710: I/System.out(2970): AUTH LOGIN04-07 14:06:05.754: I/System.out(2970): 334 VXNlcm5hbWU6
04-07 14:06:05.754: I/System.out(2970): MTQ0Njc5MDY4MUBxcS5jb20=
04-07 14:06:05.802: I/System.out(2970): DEBUG SMTP: EOF: [EOF]
04-07 14:06:05.806: W/System.err(2970): javax.mail.AuthenticationFailedException
04-07 14:06:05.806: W/System.err(2970): at javax.mail.Service.connect(Service.java:319)
04-07 14:06:05.806: W/System.err(2970): at com.example.sendemaildemo02.MailExample.send(MailExample.java:79)
04-07 14:06:05.806: W/System.err(2970): at com.example.sendemaildemo02.MainActivity$1$1.run(MainActivity.java:81)
04-07 14:06:05.806: W/System.err(2970): at java.lang.Thread.run(Thread.java:856)
解决方案
关键是qq的验证你没有通过
看看这个例子:http://blog.csdn.net/dyllove98/article/details/9371885 作者说它通过qq发邮件
解决方案二:
04-07 14:06:05.294: I/System.out(2970): DEBUG: not loading file: /system/lib/javamail.providers
04-07 14:06:05.298: I/System.out(2970): DEBUG: java.io.FileNotFoundException: /system/lib/javamail.providers: open failed: ENOENT (No such file or directory)
找不到邮件的provider,后面还有address map没找到,不过最关键的是
04-07 14:06:05.806: W/System.err(2970): javax.mail.AuthenticationFailedException
不过不上code,很难清楚为什么
解决方案三:
访问不到provider先看看你<权限>加了没有吧。。。
解决方案四:
这是 我的代码,实在android里面写的
send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
new Thread(new Runnable() {
@Override public void run() { try{ String userName=""17764576391@163.com""; String password=""******""; String smtp_server=""smtp.163.com""; String from_mail_address=userName; String to_mail_address=""345521625@qq.com""; Authenticator auth=new PopupAuthenticator(userNamepassword); Properties mailProps=new Properties(); mailProps.put(""mail.smtp.host"" smtp_server); mailProps.put(""mail.smtp.auth""true""); mailProps.put(""username"" userName); mailProps.put(""password"" password); Session mailSession=Session.getDefaultInstance(mailProps auth); mailSession.setDebug(true); MimeMessage message=new MimeMessage(mailSession); message.setFrom(new InternetAddress(from_mail_address)); message.setRecipient(Message.RecipientType.TO new InternetAddress(to_mail_address)); message.setSubject(""Mail Testw""); MimeMultipart multi=new MimeMultipart(); BodyPart textBodyPart=new MimeBodyPart(); textBodyPart.setText(""电子邮件测试内容w""); //textBodyPart.setFileName(""37af4739a11fc9d6b311c712.jpg""); multi.addBodyPart(textBodyPart); message.setContent(multi); message.saveChanges(); Transport transport = mailSession.getTransport(""smtp""); transport.connect(""smtp.163.com""251446790681@163.com""******""); transport.sendMessage(message message.getRecipients(Message.RecipientType.TO));//发送邮件其中第二个参数是所有已设好的收件人地址 transport.close(); }catch(Exception ex){ System.err.println(""邮件发送失败的原因是:""+ex.getMessage()); System.err.println(""具体的错误原因""); ex.printStackTrace(System.err); } } }){ }.start(); Toast.makeText(getApplicationContext()发送成功""3000).show(); } });}class PopupAuthenticator extends Authenticator{ private String username; private String password; public PopupAuthenticator(String usernameString pwd){ this.username=username; this.password=pwd;}public PasswordAuthentication getPasswordAuthentication(){ return new PasswordAuthentication(this.usernamethis.password); }}
解决方案五:
解决了吗?怎么解决的。