3

I am using org.springframework.mail.javamail.JavaMailSenderImpl for mail sending and here is the piece of code which is working fine. emailArray is an array of 5 recipients email ids. But I want to use a DL for this rather than creating an array of email ids. How can I do it?

MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(<sender email id>);
helper.setSubject("test");
String[] emailArray = new String[5];
helper.setTo(emailArray);
helper.setText(body, true);
javaMailSender.send(mimeMessage);
Amaresh
  • 331
  • 2
  • 5
  • 14

2 Answers2

0

You need to create the distribution list in your mail server, then just use the distribution list address in your JavaMail message. JavaMail does not include APIs for creating distribution lists since there's no standard internet protocol for doing so and how it's done varies widely from mail server to mail server.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • I tried passing distribution list address instead of emailArray but no result, no exception. – Amaresh Mar 15 '14 at 08:26
  • If your server accepted the message without complaint, then you need to look on your server to figure out why it never delivered the message to the distribution list. Can you send email to that distribution list using other email clients such as Thunderbird? – Bill Shannon Mar 15 '14 at 21:42
0

I had to call microsoft exchange apis to first expand the DL.

Amaresh
  • 331
  • 2
  • 5
  • 14