java - Must issue a STARTTLS command first -


i running simple example gmail account, not working , giving following error:

      send failed, exception: com.sun.mail.smtp.smtpsendfailedexception: 530 5.7.0 must issue starttls command first. nv2sm4478384pbb.6       

here code

   public class email {    public static void main(string [] args)    {         properties props = new properties();         props.put("mail.smtp.host", "smtp.googlemail.com");         props.put("mail.from", "myemail@gmail.com");           session session = session.getinstance(props, null);          try {             mimemessage msg = new mimemessage(session);             msg.setfrom();             msg.setrecipients(message.recipienttype.to,                               "myemail@hotmail.com");             msg.setsubject("javamail hello world example");             msg.setsentdate(new date());             msg.settext("hello, world!\n");             transport.send(msg);         } catch (messagingexception mex) {             system.out.println("send failed, exception: " + mex);         }    } } 

you attempting use gmail's servers on port 25 deliver mail third party on unauthenticated connection. gmail doesn't let this, because anybody use gmail's servers send mail else. called open relay , common enabler of spam in days. open relays no longer acceptable on internet.

you need ask smtp client connect gmail using authenticated connection, on port 587.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -