Email 从web应用发送电子邮件的推荐方式?
我在JBoss4.2.3上有一个web应用程序,我希望它能发送电子邮件。我可以这样做:Email 从web应用发送电子邮件的推荐方式?,email,jboss,jakarta-ee,smtp,jakarta-mail,Email,Jboss,Jakarta Ee,Smtp,Jakarta Mail,我在JBoss4.2.3上有一个web应用程序,我希望它能发送电子邮件。我可以这样做: 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("m
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("me@somehost.com"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("recipient@somewhere.com", 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);
}
但这感觉不对。这会扩展吗?使用Spring时,您要发送多少条消息?你有没有测量过上面提到的跑步需要多长时间?(我假设主要的时间消耗将是发送给MTA的实际
send()
。这是否重要是另一回事)
也许: