Faiyaz Md Abdul
Faiyaz Md Abdul

Reputation: 667

How to set a value to a key in application.conf file in Play Framework (Java) 2.3.x

I have Play mailer configured on application.conf file with one email id . how can i change the email dynamically during run time ? The idea is to configure multiple email IDs on a single play application . eg ; for sales , the email must be sent from [email protected] and for purchase , [email protected]

smtp.host=smtp.zoho.com
smtp.port=465
smtp.ssl=true
smtp.user= "[email protected]"
smtp.password= "something"

i can get the string value using Play.application().configuration().getString("smtp.host"); ; how do we set it during run time ?

Upvotes: 2

Views: 1600

Answers (2)

user2595529
user2595529

Reputation: 171

The recipients of emails are set in your code, using the addTo method on a play.libs.mailer.Email object : https://github.com/playframework/play-mailer/blob/2.x/sample/app/controllers/ApplicationJava.java#L18

Not to be confused with the login and password of your SMTP provider. These are sets in application.conf : https://github.com/playframework/play-mailer/blob/2.x/sample/conf/application.conf#L65

Upvotes: 0

Vladimir Korenev
Vladimir Korenev

Reputation: 1166

Play Configuration wraps Typesafe Config, which is immutable. So you cannot modify a config after creation. You can only create another config based on this one, overriding some properties.

Upvotes: 3

Related Questions