android - transport.connect is not doing anything javamail -
i send emails using javamail. have class able (few months ago send emails), program stops on transport.connect(emailhost, from, frompassword);
sendmails activity:
public class sendmails { final string smtpauth = "true"; final string starttls = "true"; final string emailhost = "smtp.gmail.com"; string fromemail; string frompassword; list<string> toemaillist; string emailsubject; string emailbody; string emailport; properties emailproperties; session mailsession; mimemessage emailmessage; private emailaccount account; private emailauthenticator authenticator; public sendmails() { } public sendmails(string fromemail, string frompassword, list<string> toemaillist, string emailsubject, string emailbody, string emailport) { this.fromemail = fromemail; this.frompassword = frompassword; this.toemaillist = toemaillist; this.emailsubject = emailsubject; this.emailbody = emailbody; this.emailport = emailport; string[] splited = fromemail.split("@"); log.w("send mails", splited[0] + "+" + splited[1]); account = new emailaccount(splited[0], frompassword, splited[1]); authenticator = new emailauthenticator(account); log.w("sendmails", " " + emailport); emailproperties = system.getproperties(); emailproperties.put("mail.smtp.port", this.emailport); emailproperties.put("mail.smtp.auth", smtpauth); emailproperties.put("mail.smtp.starttls.enable", starttls); } public mimemessage createemailmessage() throws addressexception, messagingexception, unsupportedencodingexception { mailsession = session.getdefaultinstance(emailproperties, null); emailmessage = new mimemessage(mailsession); emailmessage.setfrom(new internetaddress(fromemail, fromemail)); (string toemail : toemaillist) { log.i("gmail", "toemail: " + toemail); emailmessage.addrecipient(message.recipienttype.to, new internetaddress(toemail)); } emailmessage.setsubject(emailsubject); // emailmessage.setcontent(emailbody, "text/html");// html email emailmessage.settext(emailbody);// text email log.i("gmail", "email message created."); return emailmessage; } public void sendemail() throws addressexception, messagingexception { transport transport = mailsession.gettransport("smtp"); log.i("gmail", "all: " + emailhost + " " + fromemail + " " + frompassword + " " + emailmessage.tostring()+ " " + fromemail.split("@")[0].tostring()); string = fromemail.split("@")[0].tostring(); log.i("gmail", "from: " + from); try { transport.connect(emailhost, from, frompassword); } catch (exception e) { e.printstacktrace(); } log.i("gmail", "allrecipients: " + emailmessage.getallrecipients()); transport.sendmessage(emailmessage, emailmessage.getallrecipients()); transport.close(); log.i("gmail", "email sent successfully."); } }
the last log log.i("gmail", "from: " + from); , log.i("gmail", "allrecipients: " + emailmessage.getallrecipients()); never shown ...also no exceptions thrown ..
thanks lot :)
//edit
03-24 22:49:00.090: i/system.out(12018): debug: setdebug: javamail version 1.4.7 03-24 22:49:00.190: i/system.out(12018): debug: getprovider() returning javax.mail.provider[transport,smtp,com.sun.mail.smtp.smtptransport,sun microsystems, inc.,1.4.7] 03-24 22:49:00.220: i/system.out(12018): debug smtp: useehlo true, useauth true 03-24 22:49:00.220: i/system.out(12018): debug smtp: trying connect host "smtp.tuke.sk", port 465, isssl false
add mailsession.setdebug(true); output show?
Comments
Post a Comment