Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to skip everyone group while sending mail

Avatar

Level 2

We are having workflow which will publish pages/assets to lower environments (Prod author to Pre-Prod author and Pre-Prod publisher) first...After that the content will be manually validated in lower environment (Pre-Prod author and Pre-Prod publisher) and will be pushed to corresponding publishers (Prod publishers).

There are some set of groups(Configurable in OSGi) who can initiate the workflow. If any unauthorized user initiates the workflow , then a mail will be triggered to all group members (To which that initiator belongs to). In AEM6.1 there is a group called "everyone", which is by default part of all the groups we create. So whenver a mail is getting triggered, it is going to all the members of everyone group also. I don't want to send the mail to the members of everyone group. Can somebody please suggest on how to skip this everyone group.

 

Thanks,

Arnab

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi arnab26

 

To send email from AEM to limited set of users, write an OSGi bundle that uses Java Mail API and you can send email.  Now having said that - there may be libs that you need to deploy in bundle fragments to get an OSGi bundle using Java mail API working. 

Please have a look at the following link doing above stated Link: -https://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

 

OR

 

 OSGI bundle and can call it using Sling servlet or as a Service. Please have a look at the code below:-

String to = "sonoojaiswal1988@gmail.com";//change accordingly 

String from = "sonoojaiswal1987@gmail.com";change accordingly 

String host = "localhost";//or IP address 

     //Get the session object 

Properties properties = System.getProperties(); 

properties.setProperty("mail.smtp.host", host); 

Session session = Session.getDefaultInstance(properties); 

    //compose the message 

         MimeMessage message = new MimeMessage(session); 

         message.setFrom(new InternetAddress(from)); 

         message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); 

         message.setSubject("Ping"); 

         message.setText("Hello, this is example of sending email  "); 

    // Send message 

         Transport.send(message); 

         System.out.println("message sent successfully....");    

You may use this code in doPost/doGet methods of OSGi when using it as Sling Servlet else you can use in some method of OSGI class and can invoke from JSP when using it as OSGI service.

I hope this will help you.

 

Thanks and Regards

Kautuk Sahni

View solution in original post

1 Reply

Avatar

Correct answer by
Administrator

Hi arnab26

 

To send email from AEM to limited set of users, write an OSGi bundle that uses Java Mail API and you can send email.  Now having said that - there may be libs that you need to deploy in bundle fragments to get an OSGi bundle using Java mail API working. 

Please have a look at the following link doing above stated Link: -https://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

 

OR

 

 OSGI bundle and can call it using Sling servlet or as a Service. Please have a look at the code below:-

String to = "sonoojaiswal1988@gmail.com";//change accordingly 

String from = "sonoojaiswal1987@gmail.com";change accordingly 

String host = "localhost";//or IP address 

     //Get the session object 

Properties properties = System.getProperties(); 

properties.setProperty("mail.smtp.host", host); 

Session session = Session.getDefaultInstance(properties); 

    //compose the message 

         MimeMessage message = new MimeMessage(session); 

         message.setFrom(new InternetAddress(from)); 

         message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); 

         message.setSubject("Ping"); 

         message.setText("Hello, this is example of sending email  "); 

    // Send message 

         Transport.send(message); 

         System.out.println("message sent successfully....");    

You may use this code in doPost/doGet methods of OSGi when using it as Sling Servlet else you can use in some method of OSGI class and can invoke from JSP when using it as OSGI service.

I hope this will help you.

 

Thanks and Regards

Kautuk Sahni