Loading

How to configure Email connector to use multiple email addresses loaded from a .properties file on Mule

Julkaisupäivä: Jul 17, 2025
Tehtävä

GOAL

The following steps show how to use the Email Connector in Mule Runtime 4 to send messages over SMTP to multiple email addresses (comma separated) configured on a property file
Vaiheet

In this example, we will use, besides the Email Connector:
A Scheduler component, that will trigger the flow execution.
A setPayload component, that sets the message content we will send to the email Addresses.
A property file that will contain the email Addresses this file needs to be placed the project's src/main/resources folder

First you need to configure property to be used for use in Mule app

<configuration-properties doc:name="Configuration properties" doc:id="84071604-43ac-4917-9904-b5a1331ecc74" file="application.properties" doc:id="84071604-43ac-4917-9904-b5a1331ecc74"/>


The email connector only need to be pointed to the property that contains the email addresses. The easiest way to achieve this is configuring the addresses as an expression.
Using the p function to point to the property that contains the emails, and since the addresses are comma separated, we will user the splitBy function, this will split these values into an array of separate elements.
 

<email:send doc:name="Send" fromAddress="test.mule.imaps@gmail.com" config-ref="Email_SMTP" subject="Hello World Subject" toAddresses="#[p('emails')splitBy(&quot;,&quot;)]">
</email:send>


More details on the functions used can be found in our documentation:
https://docs.mulesoft.com/dataweave/latest/dw-mule-functions-p

Knowledge-artikkelin numero

001114454

 
Ladataan
Salesforce Help | Article