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

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
Adobe Summit 2023 | Complete list of AEM Sessions & Labs

Can I update "From" address/ Sender from Day CQ mail service at runtime ?


Level 4

Hi Leads,

Thanks in advance.


I want to change the sender means "From" address while using Day Mail Service in AEM 6.5. I have tried but it takes only STMP user email as sender. New values are not picked for sending mail- email.setFrom(from);






3 Replies


Community Advisor

Hey @sanketd27011989 

In the screenshot, I don't see any email in the field "From address". Have you tried putting some email there and triggering your functionality? I think that email would pick in your "From" in the email.



Arpit Varshney


Level 4

Yes tried with this "from" address field  then only that value picked. I am not able to change at runtime


Community Advisor


 You can change this value by configuring the Day CQ mail service

service in the Web Console.

To configure the from-email address, add a sling:OsgiConfig node to the repository. Use the following procedure to add the node directly using CRXDE Lite

When working with AEM there are several methods of managing the configuration settings for such services; see Configuring OSGi for more details and the recommended practices.


Community Advisor

Hi @sanketd27011989 


Yes, you can update the "From Address". If you are using the Email object then you can set the from address to it.

Email email;

I tested it out and was able to change the from address dynamically. Please let me know if this works for you.







Community Advisor

I'm not sure why it didn't work for you. I have written a sample servlet to test this scenario. Pasting the whole servlet code below.


import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.MultiPartEmail;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import javax.servlet.Servlet;
import javax.servlet.ServletException;

@Component(service = Servlet.class,
        property = {
                "sling.servlet.paths=" + "/bin/abc/testmail",
                "sling.servlet.methods=" + "GET"
public class TestMailServlet extends SlingSafeMethodsServlet {

    protected transient MailService mailService;

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {

        try {
            Email email = new MultiPartEmail();
        } catch (EmailException e) {




Level 4


I have tried your solution but still, I am getting mail from the sender which is configured in the AEM CQ mail service with valid credentials.

I am getting emails on my Gmail ID.but the new sender is not reflected.


Community Advisor

Is there any specific reason you have for using Gmail as SMTP? If it is only for testing in your local you can use fakeSMTP which is great for testing email functionalities. The setup is pretty easy and straightforward. Do let me know if you have queries relating to setting it up.


If you have to use only Gmail for any specific reason, do let me know and I'll give it a try with Gmail as an SMTP server and let you know how it goes.


Level 4

Hi All,

 I have used it the below code and it's working as of now.but thing this is not proper way.


Configuration configuration = configAdmin.getConfiguration("");

if (configuration != null) {

// get properties

Dictionary<String, Object> properties = configuration.getProperties();

Dictionary<String, Object> newProperties = properties;

// update properties
if(properties == null)
newProperties = new Hashtable<String, Object>();

// update new properties



// revert to old property




Thanks Sanket