2009-07-07 1 views
1

JBoss 4.2.3에 웹 응용 프로그램이있어서 전자 메일을 보내고 싶습니다. 나는 다음과 같이 할 수있다 :웹 앱에서 이메일을 보내는 데 권장되는 방법은 무엇입니까?

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); 
} 

그러나 그것은 옳지 않다. 이 규모가 될까요? 스프링

답변

1

얼마나 많은 메시지는 보내는을 사용할 수 있습니까? 위를 실행하는 데 걸리는 시간을 측정 했습니까?

  1. 당신이 당신의 MTA에 보내는 메시지를 대기 할 필요가 : 아마도

    (. 내가 주요 시간 싱크는 MTA의 실제 send()에있을 것입니다 있으리라 믿고있어 그 의미의 여부는 또 다른 문제이다) 대기열에 넣고 별도의 스레드에서 전송을 실행 하시겠습니까?

  2. 적절한 메일 링리스트/별칭이 설정되어있어 'n'명의 수신자에게만 하나의 메일 만 보내시겠습니까?

그러나 보내려는 메시지의 수와받는 사람의 집합이 얼마나 다른지에 달려 있습니다.