I have created an email account for admin of my web site using google's gmail app as admin@mywebsite.com. I am able to login using the credentials on gmail's login web page. Now i want to send email using java and this id
String host = "smtp.gmail.com";
String from = "admin@mywebsite.com";
String pass = "myPass";
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
....
...
...
Session session = Session.getDefaultInstance(props, auth);
...
...
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
This is throwing an exception as Exception in thread "main" javax.mail.AuthenticationFailedException
However, when i try this with gmail credentials (myid@gmail.com), it works. Please help me out on this. Thanks in advance