About Custom Email Step and Day CQ Mail Service | Community
Skip to main content
Level 2
April 4, 2019

About Custom Email Step and Day CQ Mail Service

  • April 4, 2019
  • 2 replies
  • 5712 views

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?

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

arunpatidar
Community Advisor
Community Advisor
April 4, 2019

No, It should send mail from the email address which you are setting in code e.g. email.setFrom("abc.xyz@forum.com")

Please check below

Adobe Experience Manager Help | Creating custom AEM workflow steps that send email messages

Arun Patidar
k_raAuthor
Level 2
April 4, 2019

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.setSubject(subject);

email.addTo(emailId);

email.setContent(emailMessage, "text/html; charset=utf-8");

email.setFrom("xyz@gmail.com");

messageGateway.send((Email) email);

April 4, 2019

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

email.setFrom(params.get("senderEmailAddress"));

email.setTo(recipients);

final MessageGateway<Email> messageGateway = messageGatewayService.getGateway(mailType);

messageGateway.send(email);

ruchim
Level 2
May 26, 2019

We are facing the same issue. Were you able to find a fix for this?

k_raAuthor
Level 2
May 28, 2019

no

k_raAuthor
Level 2
May 28, 2019

This seems to be an issue if we use google SMTP. I tried with the settings of a fake smtp server and it worked fine.


good to know, Thanks.