Hi,
Please somebody help me. I'm programming a Java Room Booking application where the user is required to give details... with an email address being one of them. I want the send an email to the address given as a receipt.
Anyway, it's not working for some reason and I have no idea why. Any help would be great!
Feel free to suggest anything as I'm desperate.
Thanks
public static void sendMail(String e) { final String SMTP_HOST_NAME = "smtp.gmail.com"; final int SMTP_HOST_PORT = 465; final String SMTP_AUTH_USER = ""; final String SMTP_AUTH_PWD = ""; Properties props = new Properties(); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.host", "smtp.gmail.com"); props.setProperty("mail.user", ""); props.setProperty("mail.password", ""); System.out.println("One"); try { Session mailSession = Session.getDefaultInstance(props, null); Transport transport = mailSession.getTransport(); MimeMessage message = new MimeMessage(mailSession); message.setSubject("Room Booking Confirmation"); message.setContent("This is a test", "text/plain"); message.addRecipient(Message.RecipientType.TO, new InternetAddress(e)); System.out.println("Two"); transport.connect(SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD); transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO)); System.out.println("Three"); transport.close(); } catch (MessagingException ex) { System.out.println(ex); } }