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

Send an email when creating an account #16

Open
BananeGuimauve opened this issue Jul 10, 2019 · 6 comments
Open

Send an email when creating an account #16

BananeGuimauve opened this issue Jul 10, 2019 · 6 comments

Comments

@BananeGuimauve
Copy link
Contributor

In the Java version, when creating an account, a user receives directly in his mailbox a confirmation email. We want to replicate this behavior in the .Net version. Another question then arises, where to store the templates of the mails ?

@ivanmonteiro
Copy link
Contributor

ivanmonteiro commented Jun 19, 2020

The templates of the emails could be stored as razor templates, the same template files of asp.net core/mvc.
Maybe the folder for email razor templates could be stored at Views/Mails or Views/Shared/Mails.
With this, we can pass a Model object, like WelcomeMailModel, use it on the view and get the final html that will be used on the email.
Email Model classes could be stored at Models/Mails subfolder.

For reference:
https://www.c-sharpcorner.com/article/send-email-from-a-razor-page-in-net-core-2-using-system-net-mail/
https://corstianboerman.com/2020-01-07/sending-transactional-emails-from-asp-net-core.html

@nicolas63
Copy link
Member

I think is a good idea 😄
Can you try an implementation ?

@nicolas63 nicolas63 modified the milestones: 1.1.0, 1.2.0 Aug 21, 2020
@nicolas63 nicolas63 mentioned this issue Sep 18, 2020
@nicolas63 nicolas63 removed this from the 1.2.0 milestone Dec 25, 2020
@duymap
Copy link

duymap commented May 22, 2022

Sending emails is a very common feature and is always needs for any project. So if having it in place, would be a big help for developers. E.g we can have mail sending code function implementation in MailService.cs, it reads config from JSON setting file, and developers replace their STMP information. This has been mentioned in this issue #1036

@ivanmonteiro
Copy link
Contributor

ivanmonteiro commented Jun 17, 2022

@duymap Yes, It is a very common feature.

It has been a long time since I did the coment above. There are libraries that do exactly what I described such as FluentEmail. But even a very simple email sending solution like SmtpClient should be enough.

By the way, seems that Microsoft docs do not recommend using SmtpClient in new development due to the lack of modern protocols (see the full explanation here) and recommends using MailKit instead, or other email libraries.

If you're willing to implement this and needs any help or assistance don't be afraid to ask

@duymap
Copy link

duymap commented Jun 21, 2022

Yes, willing to do. Just quick questions to ask for speeding up:

  • What are the templates code located?
  • Develop is the latest branch that I should branch off, then create PR ?

@ivanmonteiro
Copy link
Contributor

ivanmonteiro commented Jun 21, 2022

Yes, willing to do. Just quick questions to ask for speeding up:

  • What are the templates code located?

Here is the MailService class:
https://github.com/jhipster/jhipster-dotnetcore/blob/main/generators/server/templates/dotnetcore/src/Project.Domain.Services/MailService.cs.ejs

And smtp credentials/configuration shoud be added at SecuritySettings class:
https://github.com/jhipster/jhipster-dotnetcore/blob/main/generators/server/templates/dotnetcore/src/Project.Infrastructure/Configuration/SecuritySettings.cs.ejs

SecuritySettings class is loaded with information from appsettings.{environment}.json during startup

  • Develop is the latest branch that I should branch off, then create PR ?

It seems that develop is outdated.
You shoud create a branch from main and then create a PR here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants