0

Why is it not sending this email ? my log. i is executing it right on the run time but no emails are send out.

findViewById(R.id.feedback_submit).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            try {   
                GMailSender sender = new GMailSender("senderemailaddress@gmail.com", "password");
                sender.sendMail("This is Subject",   
                        "This is Body",   
                        "senderemailaddress@gmail.com",   
                        "recipientemailaddress@gmail.com");   
             Log.i("Status", "Working");
            } catch (Exception e) {   
               Log.i("Status", "Not Working");
                Log.e("SendMail", e.getMessage(), e);   
            } 
}
dark_illusion_909099
  • 1,067
  • 2
  • 21
  • 41
  • I followed this post and did everything that this post has mentioned - http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a – dark_illusion_909099 Mar 31 '15 at 12:39

1 Answers1

0

Since you are using GMailSender any exception thrown will be consumed by the class and you will have no way of knowing whether the mail was sent successfully or not.

I had a problem like that once, make sure that the network you are in is allowed to send mails. It has to do with the way SMTP protocol is setup. I suggest you use the JavaMail API you will get a better understanding of how everything works. Here's a link to a good tutorial http://www.tutorialspoint.com/java/java_sending_email.htm

Make sure all your JAR files are in your project as well

Venelin K
  • 205
  • 2
  • 10
  • I have got all the Jar files in my project. there is no errors and like I said that Log statement is outputing as its working. So no sign of any errors part from its not sending the email to the recipient – dark_illusion_909099 Mar 31 '15 at 12:42
  • The fact that your log is outputting "Working" does not mean that it actually sent the request. Once you call the sendMail method it does a server request and you can't know whether something went wrong on the way there or back. If you create your own JavaMailSender class you will have bigger control and you can pinpoint which exception is thrown and where – Venelin K Mar 31 '15 at 12:44
  • Is there anyway you could help me from looking at this?? I have made a comment on my post showing where I got all this code from – dark_illusion_909099 Mar 31 '15 at 12:49
  • The only thing I could see missing is maybe having this in your app manifest: If this does not working start commenting out pieces of code and step through it to see whether something fails. Go in increments, comment out entire methods and then little by little you can narrow down the problematic paths. It's a matter of debugging the code. You could think everything is fine but you may be missing a line – Venelin K Mar 31 '15 at 12:54
  • Yeah I got that bit on my manifest, ohh alright I will do that then – dark_illusion_909099 Mar 31 '15 at 12:58
  • Sorry sometimes you just have to look into the code, put logs everywhere to get a better sense of what your code is doing – Venelin K Mar 31 '15 at 13:02