Issue in sending Auto Email in Android applicaiton -


Hello friends, I want to send an email from my Android appetire so that my code

  is public OnClickListener {session session = zero; on the implementation of class main activity activity; Progress Dioco pdialog = null; Reference reference = null; Edit text resident = empty; Edit text sub = null; EditText msg = null; String repipent = null; String subject = null; String text message = null; @ Override Protected Zero (InstanceStat saved from bundle) {// Todo auto-generated method stub super. Connet (Saved Instantstate); SetContentView (R.layout.activity_main); Context = this; Button Login = (button) Find VVBIID (RID mbtnsmit); Receipt = (EditText) findViewById (R.id.editText_to); Find sub = (edit text) VVBIID (RID.edittext_sub); Msg = (Editing Text) findViewById (R.id.editText_text); Login.setOnClickListener (this); } @ Override Public Zero (see V) {recpient = reciept.getText (). ToString (); Subject = sub.gettext (). ToString (); Textmessage = msg.getText (). ToString (); Properties PRO = new property (); Props.put ("mail.smtp.host", "smtp.gmail.com"); Props.put ("mail.smtp.socketFactory.port", "465"); Prospect ("mail SMTP socket factory class", "javax.net.ssl.SSLSocketFactory"); Props.put ("mail.smtp.auth", "true"); Props.put ("mail.smtp.port", "465"); Session = session.getDefaultInstance (support, new javax.mail.Authenticator () {secure passwordAction getPasswordAuthentication ()} New passwordAuthication ("abc@a.a", "password");}}); Pdialog = ProgressDialog.show (context, "", "sending mail ...", true); RetreiveFeedTask function = New RetreiveFeedTask (); Task.execute (); } Class RetreiveFeedTask increases AsyncTask & lt; String, zero, string & gt; {Secure string doInBackground (string ... url) {try {message message = new mime message (session); Message.setFrom (new internet address ("abc@a.a")); Message.setRecipients (Message.RecipientType.TO, InternetAddress.parse (recpient)); Message.setSubject (subject); Message.setContent (text message, "text / html; charset = UTF-8"); Transport.send (message); } Catch (Messaging Expression E) {e.printStackTrace (); } Hold (exception e) {e.printStackTrace (); } Return tap; } PostXtech (string feed) on protected zeros {pdialog.dismiss (); Reciept.setText (""); Msg.setText (""); Sub.setText (""); Toast. Make Text (getApplicationContext (), "Message Sent", Toast.LNNHHLOG). Show (); }}}  

and I also like jar

  activation.jar additionnal.jar mail.jar android-support-v4.jar  

When I run the code above, I give me an error

  02-18 16: 16: 05.242: W / System. Er (3242): javax.mail.MessagingException: could not connect to SMTP host: smtp.gmail.com, ports: 465; 02-18 16: 16: 05.242: W / Systems. Er (3242): The nested exception is: 02-18 16: 16: 05.242: W / Systems. Er (3242): javax.net.ssl.SSL Handshake Exception: Java Security.cert.CertPathValidatorException: Trust anchor not found for authentication path. 02-18 16: 16: 05.242: W / Systems. Er (3242): com.sun.mail.smtp.SMTP Transports. Open Server (SMTPTransport.java:1391) 02-18 16: 16: 05.242: W / System Error (3242): com.sun.mail.smtp.SMTP Transports. Protocol Connect (SMTPTransport.java:412) 02-18 16 : 16: 05.242: w / System.err (3242): at javax.mail.Service.connect (Service. Java: 310) 02-18 16: 16: 05.242: W / Systems. Er (3242): at javax.mail.Service.connect (Service.java:1269) 02-18 16: 16: 05.242: W / System.err (3242): at javax.mail.Service.connect (Service.java : 118) 02-18 16: 16: 05.242: W / Systems. Er (3242): at javax.mail.Transport.send0 ( 

Please use your valid email ID for the sender mail id and the correct password.

  GMailSender sender = new GMailSender ("pankaj.sharma101987@gmail.com", "******"); Sender SendMail ("Hi", "Pankaj Test Mail", "Pankaj Sharma 101987@gmail.com", "receiver@gmail.com");  

Here in the code, then run code.hope. This works for you.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -