Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set smtp settings though appsettings.json #6264

Closed
jersiovic opened this issue May 25, 2020 · 7 comments
Closed

Set smtp settings though appsettings.json #6264

jersiovic opened this issue May 25, 2020 · 7 comments

Comments

@jersiovic
Copy link
Contributor

jersiovic commented May 25, 2020

Is it possible to set smtp settings though appsettings.json and by extension by environment vars?
We tried it without success?

If not, would you accept a PR to allow that?

@deanmarcussen
Copy link
Member

deanmarcussen commented May 25, 2020

Duplicate of #6036

so yes, but we need to figure out how the ui copes :)

You can set them yourselves (I think @Piedone included a link in the issue) by registering your own services.AddTransient<IConfigureOptions<SmtpSettings>, SmtpSettingsConfiguration>(); or using services.PostConfigure<SmtpSettings>(x => x)

Edited Maybe we should just consider moving the email password / smtp server completely out of the ui and into appsettings.json ?

I'm guessing it's the server / passwords that you're wanting to set @jersiovic ?

@Piedone
Copy link
Member

Piedone commented May 25, 2020

You can set all the SMTP settings from configuration, including appsettings. If you want to do that from code the example there is actually for SmtpSettings too

Having SMTP settings on the UI too is useful, I'd be very much against removing it.

@cesarktp
Copy link

If I configure smtp settings from the UI, sending email works (to a file). If I don't configure the smtp settings from the UI and use this appsettings.json:

{
"OrchardCore":{
"OrchardCore.Email":{
"DefaultSender":"sender@contoso.com",
"DeliveryMethod":"SpecifiedPickupDirectory",
"PickupDirectoryLocation":"/app/App_Data",
"Host":null,
"Port":25,
"AutoSelectEncryption":false,
"RequireCredentials":false,
"UseDefaultCredentials":false,
"EncryptionMethod":"None",
"UserName":null,
"Password":null
}
}
}
email sending (to a file again) doesn't work. The appsettings.json is placed in /app/App_Data
What's wrong in the appsettings.json?

@jersiovic
Copy link
Contributor Author

@cesarktp is a felllow at the IT deparment I'm trying to make he falls in love with Orchard.
Any help with this task will be very welcome :)

@Piedone
Copy link
Member

Piedone commented May 26, 2020

I wanted to update the docs first as an answer :D.

This won't work by default. Maybe the docs is misleading, as was my message but unless the module specifically supports it you won't be able to just add such static configs. For every module supporting IOptions-based configs you can, however, set up arbitrary configuration from your web project's Startup class. If you want to load this config from appsettings (including Orchard's cascading config files) then you need to retrieve those values via IShellConfiguration.

@jersiovic
Copy link
Contributor Author

Ok very clear. we will do as you explain. Thank you!

@Piedone
Copy link
Member

Piedone commented May 26, 2020

So I think this confusion is cleared up. Added some clarification to the docs too.

@Piedone Piedone closed this as completed May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants