javamail - sending mail through java encounter error -


now days i'm facing quite strange problem & during send mails strange because when i'm testing application on localhost goes perfect deployed application enable send mails .

you guys can check http://www.mkjit-solutions.com/app/jsf/contactus.xhtml

i'm seeing exception:

javax.mail.sendfailedexception: sending failed; nested exception is: class javax.mail.messagingexception: 530 5.7.0 must issue starttls command first. yv6sm13782372pac.29 - gsmtp  

the code used

props.put("mail.smtp.host", "smtp.gmail.com");  props.put("mail.smtp.port", "587");  props.put("mail.debug", "true");  props.put("mail.smtp.auth", "true");  props.put("mail.smtp.starttls.enable", "true");   session session = session.getinstance(props,           new javax.mail.authenticator()                    {             protected passwordauthentication getpasswordauthentication()                          {                 return new passwordauthentication(useraddress, userpassword);             }           });          custommsg += "3 - ";          try {                          custommsg += "3.1 - ";             message message = new mimemessage(session);                          custommsg += "3.2 - ";             message.setfrom(new internetaddress(useraddress));                          custommsg += "3.3 -  ";                         message.setrecipients(message.recipienttype.to,                 internetaddress.parse(toaddress));                          custommsg += "3.4 -  ";                         message.setsubject(subject);                          custommsg += "3.5 -  ";                         message.settext(msg);                          custommsg += "3.6 -  ";  transport transport = session.gettransport("smtp");             transport.send(message);                    custommsg += "4 -  ";                       system.out.println("ua"+useraddress);                     system.out.println(""+userpassword);                     system.out.println("ta"+toaddress);                       system.out.println("done");                         flag = true;                         custommsg += " [value of flag "+flag+"] ";         }                  catch (exception ex)                  {                     system.out.println("");                     ex.printstacktrace();                     flag = false;                     custommsg += " [value of flag "+flag+"] ";                     this.e = ex;                     //throw new runtimeexception(e);          }                  return flag; 

start fixing these common mistakes.

gmail sample code in javamail faq.

if still can't work, follow these debugging tips, , post results.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -