Hi everyone,
I am using acs aem commons email service for sending email.
I have written the code as per the documentation and given the acs commons user permission, but the sendEmail method returning the emailId ideally it should return the empty response as per the documention.
failureList = emailService.sendEmail(emailDetails.getTemplatePath(), emailDetails.getEmailParams(),
recipient);
I have checked and debug the code but I am unbale to find the issue.
Please let me know let me know if anyone has any idea on this.
PS: I follow https://adobe-consulting-services.github.io/acs-aem-commons/features/e-mail/email-api/index.html
url for reference.
@Jörg_Hoh @VeenaVikraman Can you please help.
Thanks,
Views
Replies
Total Likes
Just checking if you have configured CQ Mail service correctly [1] ?
Yes, I have filled the day cq mail also. PFB SS:
Please let me know If I missed something
Thanks
Hi @kkhan_123
Have you configured the SMTP configurations for your testing environment ?
Check the error logs if any error or network issues are thrown.
HI @kkhan_123
Sometime if you are in your office network, this issue may arise due to network issues. Can you try in your home network or by connecting your mobile hotspot?
Hope this helps!
Thanks,
Kiran Vedantam.
Hi @Kiran_Vedantam
I already tried with different network, still not getting the email. Don’t know what I am missing here.
Thanks for the reply.
Hi @kkhan_123
Just try this once.
The sendMail(..)
method now supports the following signature:
public List<String> sendEmail(String templatePath, Map<String, String> emailParams, Map<String, DataSource> attachments, String... recipients)
public List<InternetAddress> sendEmail(String templatePath, Map<String, String> emailParams, Map<String, DataSource> attachments, InternetAddress... recipients)
Thanks
Hi @KNan ,
Tried the same still not getting the mail. Attaching the log information.
try{ ObjectMapper objMapper = new ObjectMapper(); Map<String, DataSource> attachments = new HashMap<>(); String attachmentContentsAsString = "This text should be in the attache txt file."; attachments.put("attachment1.txt", new ByteArrayDataSource(attachmentContentsAsString, "text/plain")); LOG.info("attachments value check-->{}", attachments); emailDetails.setTemplatePath(config.getShareFriendTemplate()); LOG.info("emailParams -->{}", objMapper.convertValue(emailDetails, Map.class)); Map<String, String> emailParams = objMapper.convertValue(emailDetails, Map.class); emailParams.remove("emailParams"); LOG.info("emaildetails before-->{}", emailDetails); emailDetails.setEmailParams(emailParams); LOG.info("template path {}", emailDetails.getTemplatePath()); LOG.info("params path {}", emailDetails.getEmailParams()); LOG.info("recipient path {}", emailDetails.getRecipients()); String[] recipient = {emailDetails.getRecipients(), "aaqibkhan.3may@gmail.com"}; failureList = emailService.sendEmail(emailDetails.getTemplatePath(), emailDetails.getEmailParams(),attachments, recipient); if (failureList.isEmpty()) { LOG.info("Email sent successfully to {} recipients", failureList.size()); } else { LOG.info("Email sent failed:{}",failureList); } }catch(Exception e){ LOG.info("Exception value check:{}->", e); } return failureList.size(); }
Please let me know if you need any other information.
Thanks.
If you want, you can try below solution for sending an email
https://aemlab.blogspot.com/2019/06/aem-custom-templated-email.html
Hi @arunpatidar
Tried the approach mentioned in the blog getting the email sent response but still not getting email.
I also hit the servlet path here also I am getting sent email reponse.
@Override protected void doGet(final SlingHttpServletRequest req, final SlingHttpServletResponse resp) throws ServerException, IOException { try { resp.setContentType("text/html"); PrintWriter pw = resp.getWriter(); Node templateNode = req.getResourceResolver().getResource(EMAIL_TEMPLATE).adaptTo(Node.class); final Map<String, String> parameters = new HashMap<String, String>(); parameters.put("title", "Demo Email"); parameters.put("name", "AAQIB"); parameters.put("id", "0001"); parameters.put("host.prefix", "http://localhost"); parameters.put("faqpath", "/content/AEM63App/faq.html"); final MailTemplate mailTemplate = MailTemplate.create(EMAIL_TEMPLATE, templateNode.getSession()); HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(parameters), HtmlEmail.class); email.setSubject("AEM - Demo Email for Templated email"); email.addTo("aaqibkhan.3may@gmail.com"); MessageGateway<HtmlEmail> messageGateway = messageGatewayService.getGateway(HtmlEmail.class); messageGateway.send(email); pw.write("email sent"); pw.close(); } catch (Exception e) { log.info("Exception check:{}->",e); resp.getWriter().write(e.getMessage()); resp.getWriter().close(); } }
Could you please tell me where I am making mistake.
Thanks,
Hi,
The problem could be at email server/SMTP server side.
The the email queue or try using gmail/any other SMTP server for testing.Could be firewall also.
Thanks for the reply @arunpatidar
I have added different SMTP host also still not getting email.
What error are you getting, can you add the screen shot. If no error and only empty response, that means emails have been triggered from ACS Tool on AEM. (screen shot attached)
If these email notifications have not been received, then there is an issue on the other end and not on AEM end.
Hi @krati_garg ,
FailureList returning email, but ideally it should return the empty response.
PFB SS:
Thanks for the reply.
Hi @krati_garg ,
After adding the different host getting the empty response which is correct one according to the document ,but still not getting the email.
Thanks,
@kkhan_123 I believe, if the email is sent, then there must be an issue with Recipient's network - firewall
Thanks for the reply @krati_garg
How to resolve the above issue Actually I have added different email I’d as recipient but still not getting the email(for example personal emails and company email)
hi @kkhan_123 running in to same issue . did you find any resolution?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies