Hi,
I am creating a form, which will send out the details via email upon user completes his details and click submit.
Mail Submission with JavaMail:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
try {
String host = "localhost";
String from = "[email protected]";
try {
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.debug", "true");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
Transport transport = session.getTransport("smtp");
MimeMessage message = new MimeMessage(session);
Address fromAddress = new InternetAddress("[email protected]");
message.setFrom(fromAddress);
InternetAddress to = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Email Details Sending");
message.setText("This is my testing content.");
transport.connect(host, from);
message.saveChanges();
Transport.send(message);
transport.close();
} finally {
out.close();
}
}
I am using Email aliases for [email protected] which means I could have 4 email aliases from sendToAliases. However, I am unable to reach any emails upon deploying and running the above mail file. Can anyone please advise me?
Thank you.