gpc / grails-mail

The Grails Mail Plugin
http://grails.org/plugin/mail
Apache License 2.0
45 stars 85 forks source link

grails3 override username #36

Closed noemiebolo closed 7 years ago

noemiebolo commented 7 years ago

Hello,

I would like to override grails.mail.username and grails.mail.password in the file application-development.yml.

In application.yml : grails: mail: username: user password: pass

In application-development.yml : grails: mail: username: new-user password: new-pass

I expect, in a development mode, to get new-user and new-pass as values but I only get empty strings.

Can someone explain me why ? Thanks Noémie

noemiebolo commented 7 years ago

I have opened the same issue in grails3 issues. https://github.com/grails3-plugins/mail/issues/21

ujjwol05 commented 7 years ago

create a groovy script file named as application.groovy and here is the config : grails { mail { host = "smtp.gmail.com" port = 465 username = "abc@gmail.com" password = "password" props = ["mail.smtp.auth":"true", "mail.smtp.socketFactory.port":"465", "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory", "mail.smtp.socketFactory.fallback":"false"] } }

ujjwol05 commented 7 years ago

if you want the config only on the development then

environments{ development{

            //your config here
    }

}

noemiebolo commented 7 years ago

your last comment have to be in application.groovy ? Because I'd like to get it in another file (application-development.groovy). It is this mechanism that does not work. Do you if it is possible ?

ujjwol05 commented 7 years ago

yes its on application.groovy .Write all your configs inside development if you choose for development environment.You don't have to make a separate config file for development.

noemiebolo commented 7 years ago

Thanks for your answer. I understand that I can not separate development configuration in a file. I have to put it in the main file. The reason why I want a separate file is because I don't want to commit my development login and pass.

noemiebolo commented 7 years ago

I close this post ; I have put my development configuration in the application.yml as you mentionned above. It is too bad that this plugin does not support the process of application-{env}.yml files. Never mind :) Thanks for your help !

noemiebolo commented 7 years ago

Hi, just to let know other people in the same trouble, here is the solution we finally found : In the application.yml, we had :

environments: development: locations: ['file:./application-development.yml']

Like this, we are able to put specific development configuration in a remote file that is not commited on our repository.

Hope it will help someone. Noémie.