0
Groovy 클래스에 아래 코드가 있습니다.이 메서드를 다양한 Groovy 클래스에서 비동기 적으로 호출하려고합니다.groovy의 비동기 전자 메일 알림
public void sendNotification(){
//async true
String from = ApplicationConfig.email_From;
String sendTo = ApplicationConfig.email_To;
String host = ApplicationConfig.email_Host;
String subject = ApplicationConfig.email_Subject;
String textToSend = ApplicationConfig.email_Text;
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipients(Message.RecipientType.TO, InternetAddress.parse(sendTo));
message.setSubject(subject);
message.setText(textToSend);
Transport.send(message);
}catch (MessagingException mex) {
mex.printStackTrace();
}
}
지금까지 내 요구 사항에 맞는 것을 찾을 수 없었습니다. 거기에는 일부 플러그인이 있지만, grails는 사용하지 않았습니다.