Hello Patrick! Does this method for sending emails work even if I am developing an online app for a writers' website? And more importantly, can I transfer it to different projects I'm working on by simply modifying a template? (changing the logo, the email sender, etc.)
It's my understanding that..The @code section is in the client project. When a blazor application is served to the client the entire client project is sent to the user. This project is then ran locally on their machine in the browser using web assembly (which is basically JavaScript) Meaning that the code section you refer too will be able accessible and therefore any secret will not be safe Options for this security issue are 1.) ignore it and do it anyway. Weirdly this seems to be a common suggestion online but not something I would be comfortable with. 2.) store the secret in the configuration file. I haven't looked fully into this solution however it seems that you would need to do two things to make it fully secure Move the send email logic done in this video to an API. Then call that API endpoint from the client to handle the sending of the email through MailKit. This will sort the issue of the user having access to it. Then to avoid having your SMTP username and password in the code you would have to store this on a configuration file which you then reference in the API. This means that you wont commit any passwords to GIT if your project is open source. Sorry for the really long reply. Will reply to this with an example project once I am done figuring it out!
This is awesome, but I get concerned that in a team setting people could get confused of what’s running on the client and what’s running on the server since the code looks so similar. How can you guard against this? For example if this code were to accidentally ship to the client you would have exposed email smtp creds
Good question, I had the same issue, I asked Bing Copilot and according to it the code section is running solely on the server side and is not exposed in the client's browser. But it would be great to get confirmation from some other source on this.
when is the free "The .NET 8 Web Dev Jump-Start Course" going to be available? Thx
thanks brother, i love your help , you are an excellent developer .
Hello Patrick! Does this method for sending emails work even if I am developing an online app for a writers' website? And more importantly, can I transfer it to different projects I'm working on by simply modifying a template? (changing the logo, the email sender, etc.)
Great! Do you have any plan for a video regarding Blazor SSR EditForm with elements changed using js?
Thanks a lot 💯
Thanks a lot! Very usefull. :)
Great tutorial. But is the @code{} section running in the backend and secured, not able to be seen by the end-user in their client browsers?
It's my understanding that..The @code section is in the client project. When a blazor application is served to the client the entire client project is sent to the user.
This project is then ran locally on their machine in the browser using web assembly (which is basically JavaScript)
Meaning that the code section you refer too will be able accessible and therefore any secret will not be safe
Options for this security issue are
1.) ignore it and do it anyway. Weirdly this seems to be a common suggestion online but not something I would be comfortable with.
2.) store the secret in the configuration file.
I haven't looked fully into this solution however it seems that you would need to do two things to make it fully secure
Move the send email logic done in this video to an API. Then call that API endpoint from the client to handle the sending of the email through MailKit. This will sort the issue of the user having access to it.
Then to avoid having your SMTP username and password in the code you would have to store this on a configuration file which you then reference in the API. This means that you wont commit any passwords to GIT if your project is open source.
Sorry for the really long reply. Will reply to this with an example project once I am done figuring it out!
Having looked at this more I'm incorrect! Patrick is not using Blazor WASM, he is using Blazor server
🤩
Great job ; what about navigation animation
Great 🎉. How can send html page with email ? I mean emails body incloudes style and css ?
string message = $"""
Hi there!
""";
var body = new BodyBuilder
{
HtmlBody = message
};
email.Body = body.ToMessageBody();
Good Tutorial!
This is awesome, but I get concerned that in a team setting people could get confused of what’s running on the client and what’s running on the server since the code looks so similar. How can you guard against this? For example if this code were to accidentally ship to the client you would have exposed email smtp creds
Good question, I had the same issue, I asked Bing Copilot and according to it the code section is running solely on the server side and is not exposed in the client's browser. But it would be great to get confirmation from some other source on this.
@@TheLastEmperorXiXinPig I believe bing Copilot is incorrect here. Correct me if I'm wrong