I have a web app on JBoss 4.2.3 and I'd like it to send email. I could do something like:
try {
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp" );
props.put("mail.smtp.starttls.enable","false" );
props.put("mail.smtp.host","smtp.somehost.com");
props.put("mail.smtp.auth", "true" );
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props, auth);
// -- Create a new message --
Message msg = new MimeMessage(session);
// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress("[email protected]"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[email protected]", false));
msg.setSubject("yadayada");
msg.setText("Yada yada");
// -- Set some other header information --
msg.setHeader("MyMail", "Mr. XYZ" );
msg.setSentDate(new Date());
// -- Send the message --
Transport.send(msg);
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println("Exception "+ex);
}
but it doesn't feel right. Will this scale?