I have written a custom email step in which I am using "email.setFrom(emailId)" to set the from email address for it but I see that it's not sending the mail from the from address I set using that snippet. It's actually picking up the smtp user from the Day CQ Mail Service and sending it from his email address. I am confused about it. Is it working as expected? Can anyone explain and confirm it?
Tried it many times still, its sends from SMTP user's mail address only. email.setFrom() doesn't work. The snippet I am using is below,
Email email = new SimpleEmail();
MessageGateway<Email> messageGateway = messageGatewayService.getGateway(Email.class);
email.setContent(emailMessage, "text/html; charset=utf-8");
If I use this method it will still trigger the mail from SMTP user mail address and use the name "kira" which I entered here in this snippet. (i.e from address in the mail will be "kira <STMP mail address instead of the mail address I provide in the snippet>")
Just for confirmation, I hope you are using org.apache.commons.mail.HtmlEmail or org.apache.commons.mail.SimpleEmail.
we were using since years which is working fine.
final Class<? extends Email> mailType = templatePath.endsWith(".html") ? HtmlEmail.class : SimpleEmail.class;
final Email email = mailTemplate.getEmail(StrLookup.mapLookup(params), mailType);
final MessageGateway<Email> messageGateway = messageGatewayService.getGateway(mailType);