简体   繁体   中英

Using GmailSender to send email without user interaction

I am using GMailSender class to send email without user interaction. Code is perfectly correct, it works on my Droid 3, but I just got a Samsung Galaxy S3, and it does not work. The code executes all the way up to the last statement in the try block but does not actually send the email!

So for example here the finished() method I created executes but the email never sends:

try
{
GMailSender sender = new GMailSender("someemail@gmail.com",   
                 "somepassword");
sender.sendMail(sub, mess, "someemail@gmail.com",     
"someotheremail@gmail.com");
finished();

}
catch(Exception e){
e.printStackTrace();
}

I had same problem, and the issue was wit my Gmail security, I had to activate "access from less secure apps" in Gmail options https://www.google.com/settings/security/lesssecureapps and then it worked fine.

Remember also to allow Internet permission to the Manifest.

<uses-permission android:name="android.permission.INTERNET" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM