Это видео недоступно.
Сожалеем об этом.

Send Email with a .NET 6 Web API using Mailkit & SMTP 📧

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • 🚀 Get the .NET 8 Web Dev Jump-Start Course for FREE: dotnet8.patrickgod.com
    💖 Support me on Patreon for exclusive source code access: / _patrickgod
    🐦 Let's get social on X: x.com/_PatrickGod
    🔗 Let's connect on LinkedIn: / patrickgod
    💻 GitHub: github.com/patrickgod/SimpleE...
    📚 My .NET & Blazor Udemy Courses:
    🚀 .NET Jumpstart Course: www.udemy.com/course/net-core...
    🔥 Blazor E-Commerce Course: www.udemy.com/course/blazor-e...
    🔥 Blazor Bootcamp: www.udemy.com/course/blazor-w...
    📑 Table of Contents:
    00:00 Send Email with a .NET 6 Web API using Mailkit & SMTP 📧
    01:55 Create an ASP.NET Core Web API Project
    02:33 Install Mailkit
    03:39 Create a Controller
    04:00 Use Ethereal as SMTP Service
    04:41 Implement SendEmail() method
    10:38 Test with Swagger
    11:45 Implement and Inject an EmailService
    15:52 Use the AppSettings for Host, Username & Password
    18:31 Change the Controller
    19:17 Final Test
    #DotNet #WebAPI #PatrickGod

Комментарии • 114

  • @PatrickGod
    @PatrickGod  11 месяцев назад

    🚀 Join the .NET Web Academy with a 30% discount - closing soon!
    👉 www.dotnetwebacademy.com/courses/academy?coupon=dnwas23yt

  • @GrimReaper160490
    @GrimReaper160490 2 года назад +4

    This is great Patrick! Very simple tutorial but is very useful in a practical use case especially if you need automated emails being sent out :) keep them coming

  • @bzmind_
    @bzmind_ 2 года назад +6

    Thanks for also showing the best practice to implement this, like creating IEmailService, DTO etc... that is much more helpful than you think!!! Thanks.

  • @luciopereirabrito3154
    @luciopereirabrito3154 Год назад +3

    Thank you a lot, I'm from Brazil and you helped me with this subject. I was having problems with the TSL server. However, now everything makes sense.

  • @94Andreaaa
    @94Andreaaa Год назад

    thank you man i was looking for something like this. keep up the good work.

  • @vamvdotnet
    @vamvdotnet 2 года назад

    Great video, Patrick! Way to go! :)

  • @tahirnawaz9821
    @tahirnawaz9821 6 месяцев назад +2

    Thank you so much ❤, seriously I have no words for you, God bless you

  • @Thorne991
    @Thorne991 4 месяца назад +2

    Great Job! This is the real one for Email Clients.

  • @nnasim5089
    @nnasim5089 Год назад +1

    This is Great!! Loved it

  • @angelcasanchez7229
    @angelcasanchez7229 2 года назад

    thank you very much Patrick GOD

  • @rahiyansafin449
    @rahiyansafin449 2 года назад +1

    BEST PATRICK GOD VIDEO EVER!!!!!!

  • @enhu
    @enhu 2 года назад +3

    oh my god I was literally looking for this 2 days ago, you're a life savior, god bless you!

    • @PatrickGod
      @PatrickGod  2 года назад +1

      Glad I could help! Thanks for sharing that. 😁

    • @twitterer
      @twitterer 2 года назад

      Lol @ OMG & Life savior puns

  • @krishtechie
    @krishtechie Год назад

    Thank you dude ✌️

  • @nueledem3525
    @nueledem3525 Год назад +2

    Nice one patrick. Great video!

  • @adebanjooluwasola4709
    @adebanjooluwasola4709 Год назад +1

    Amazing Video

  • @antoniorod3776
    @antoniorod3776 Год назад +1

    Thanks, your video help me a lot

  • @nirajchandrajoshi
    @nirajchandrajoshi 6 месяцев назад +1

    Hi I am new to your video and just to highlight that your way of talking is more than super actually supeeeeeeeeeeeeer.

  • @QVMaster
    @QVMaster 8 месяцев назад +1

    Very good and useful explanation❤

  • @user-zb3vl4ny4f
    @user-zb3vl4ny4f 11 месяцев назад +1

    Thanks so much

  • @shahabjoon201
    @shahabjoon201 2 года назад +17

    Perfect as always Mr. God. You bless You.

  • @PedalsizBerkay
    @PedalsizBerkay Год назад

    THANKS GOD

  • @choipatrick7006
    @choipatrick7006 2 года назад +3

    Thank you for your video. could you please explain or add to the video for sending email with attachments. really thanks.

  • @asifkhan-yi3nh
    @asifkhan-yi3nh 6 месяцев назад +1

    thanks man!!

  • @andresbeltran5779
    @andresbeltran5779 Год назад

    Nice very helpfull

  • @salvcri
    @salvcri 2 года назад +1

    Thanks a lot!

  • @bzmind_
    @bzmind_ 2 года назад

    Thank God :D

  • @allantzirin6218
    @allantzirin6218 Год назад

    Thanks bro

  • @sricharan2134
    @sricharan2134 Год назад +1

    Really nice explanation..👍🏻

  • @raphaellukas3328
    @raphaellukas3328 2 года назад +1

    Thanks for this informative video! I like it :-)

  • @sergi3056
    @sergi3056 Год назад

    Perfect

  • @moshkaffy
    @moshkaffy Год назад +1

    nice work, keep it up.

  • @user-rd4oo1jg5g
    @user-rd4oo1jg5g Год назад +1

    Very good video, is there something that is not clear to me when I send an email using an API, it is not done through an SMTP server? How would it be sent in that case?

  • @onr4087
    @onr4087 2 года назад +2

    I'm doing instant operations on data using jsonresult. Is there an easier way to do this? can you make a video about it?

  • @angelsebastianbellomateo6954
    @angelsebastianbellomateo6954 Год назад +1

    I love you Patrick

  • @EpTechie
    @EpTechie 2 года назад

    Great job 👍👏👏
    Can you do a video for Blazor Server without API?
    Thanks

  • @Mo-ef9yt
    @Mo-ef9yt 2 года назад +1

    Very nice 👍🏿

  • @brunoramirez6491
    @brunoramirez6491 Год назад

    Excellent video, Thanks.....

    • @PatrickGod
      @PatrickGod  Год назад

      You are welcome! Thanks a lot for your feedback! 😊

  • @ZestyGuy-World
    @ZestyGuy-World Год назад

    your content muaaaaa!!!!!!

  • @Ngonirow007
    @Ngonirow007 2 года назад +1

    Excellent video Patrick. My question now is how to send emails to clients that would have 2FA enable and less secure app access turned off, that is when the API is now in production. I saw a work around to send emails to Gmail accounts by having to turn 2FA and enable less secure app access which it is feasible in production

  • @grumpydeveloper69
    @grumpydeveloper69 2 года назад +1

    I always forget this as well @16:58 I prefer _ for private fields but doing this manually is cumbersome. Just set the C# CodeStyle naming convention for private fields to _camelCase and when you CTRL+. it does it for you

    • @twitterer
      @twitterer 2 года назад

      Ditto. Good suggestion.

  • @dhatuan
    @dhatuan Год назад

    thank

  • @chessgamesonline5867
    @chessgamesonline5867 2 года назад +1

    how can we send emails for example gmail adresses?

  • @nucasspro1
    @nucasspro1 2 года назад

    Could you make a video to share about read write conflict?

  • @angelcasanchez7229
    @angelcasanchez7229 2 года назад

    Is it possible to make a get by id request to a table that doesn't have a primary key?

  • @2-8ev20
    @2-8ev20 2 года назад +1

    Hello! I need to find a solution to send emails in Blazor Webassembly, but I couldn't use this method there. Is there any trick?

  • @emmanuellarteymohammed4534
    @emmanuellarteymohammed4534 2 года назад

    God!, interesting

  • @Dartarok999
    @Dartarok999 2 года назад

    patrick god, could you help me, making a video explaining how to save multiple files with inputfile but save them in a local folder and show that local path in the database, it would be very helpful since I've been trying for a long time... with blazor webassembly

  • @GoLezhaShowMega
    @GoLezhaShowMega Год назад +1

    U'r the best

  • @azgan123
    @azgan123 2 года назад +1

    Patrick is funny its hard not to like him 🤣🤣

    • @PatrickGod
      @PatrickGod  2 года назад

      Thank you very much! 😁

  • @KN-hv3gn
    @KN-hv3gn 2 года назад +1

    Hi Patrick! Great tutorial. I have a question. I have a Visual Studio solution with the Email service project and a Razor project called Visitors. How can I consume the Email project to send emails from the Visitors project?

    • @dgam8
      @dgam8 2 года назад

      I have the same question!!!!

    • @dgam8
      @dgam8 2 года назад +1

      There isn't a single video on sending Email with Mailkit using Razor or Blazor....

  • @dgam8
    @dgam8 2 года назад

    what are the chances you could do this using blazor? maybe even radzen blazor?

  • @devcharlie3377
    @devcharlie3377 2 месяца назад +1

    In the first part of the video after connecting the smtp to try out in swagger, I am getting this error when trying out the API in swagger - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

  • @reitumetsemakgatho9537
    @reitumetsemakgatho9537 2 года назад

    Hi Patrick how can I use this API in angular

  • @bennyo
    @bennyo 9 месяцев назад

    So if I implement this. I can purchase a cloud SMTP and hook into that to deliver production worthy emails?

  • @debopammandal9255
    @debopammandal9255 Год назад

    how to add attachment in this email structure

  • @bloggrammer
    @bloggrammer 2 года назад +1

    Mailkit doesn't work for WPF app, why? I tried to adapt this implementation to a WPF app but that didn't work.

  • @FerozVox
    @FerozVox Год назад

    Hi Patrick I am working on X509Certificate I need to check the revocation of certificate online and offline will help me to that if it is possible make some videos on that

  • @level1245
    @level1245 Год назад

    How to embed image in email using mailkit. Without using bodybuilder any example can give me link

  • @vci123
    @vci123 Год назад +1

    Broooooo!

  • @vtminhlien8840
    @vtminhlien8840 2 года назад

    Can you make video login with google, firebase please

  • @utsabsingh1944
    @utsabsingh1944 5 месяцев назад

    cant we use this mail service in MVC project ? i am beginner and dont know why you have to use web API for this

  • @maurirom92
    @maurirom92 2 года назад

    hi, how can I attach files?, I need attach files that are in my wwwroot folder

  • @MuhammadFaizan-rl4rp
    @MuhammadFaizan-rl4rp 4 месяца назад

    why do you have same email for both sender and recipient? usually it should be two different emails.

  • @mahydulislam
    @mahydulislam Месяц назад

    How can I receive mail using mailkit?

  • @18_arpitpatel47
    @18_arpitpatel47 Год назад

    please anyone say how to implement attachment(fileupload) in this project

  • @shahabjoon201
    @shahabjoon201 2 года назад +2

    Dear Mr. God,
    Thank you again for existing, the question is, I sent an email with the above structure (which is really perfect), but when I filled the "To" property with a real Gmail as a receiver, it sent it to the sender which is the fake email (generating by the Ethereal). Is it common or did I make a mistake?
    Thanks in advance
    Shahab

    • @bloggrammer
      @bloggrammer 2 года назад

      That's weird. Maybe you should close your VS and try again

    • @twitterer
      @twitterer 2 года назад +4

      It might be a restriction by Ethereal to stop you from using their service for production. You can simple use your own proper smtp service and it should be okay.

    • @shahabjoon201
      @shahabjoon201 2 года назад +1

      @@twitterer Thank you Hassan.

    • @yovanies2798
      @yovanies2798 Год назад +1

      Me sucedió lo mismo al usar una cuenta de GMAIL, me sale error y no envía el correo. alguna novedad sobre eso.

  • @louisszeto31620000
    @louisszeto31620000 2 года назад

    Excellent video! May I ask if I store the email password in appsetting.json is safe if I deploy the app?

    • @Chips4Real1
      @Chips4Real1 2 года назад

      dont store it there

    • @attilaguba856
      @attilaguba856 Год назад

      @@Chips4Real1 so what is the good solution, for real deployment?

  • @leonardvanonselen
    @leonardvanonselen Год назад

    Nice video👍 do you have any suggestions on which SMTP server to use in production that is able to work seamlessly with the mailkit package? Gmail , 0365 etc. all require MFA which mailkit doesn't cater for

  • @PriyadarshiPrashant
    @PriyadarshiPrashant Год назад

    When i try to pass Object (person) i got error like
    TypeError : Failed To Execute fetch on Windows Request with get /Head Method cannot have body

  • @SaikiranNomula
    @SaikiranNomula Год назад

    How can this guarantee that all the emails with attachments will send to the receiver? Is there anything I need to use to get confirmation? reply is greatly appreciated!

  • @user-cn7ec8px5e
    @user-cn7ec8px5e Год назад

    hey Actually i getting 404 error while i am testing my api of send email on postman idn why, is this beacause i am working 3.1?

  • @HiranLIVE
    @HiranLIVE 2 года назад +2

    It worked for me. BUT you need to setup an 'app password' on your Google Account if using Gmail as smtp. This is a new thing. They have deprecated the 'Less Secure App' feature.

    • @giorgichikovani4129
      @giorgichikovani4129 2 года назад

      what to do exactly in 'app password'?

    • @HiranLIVE
      @HiranLIVE 2 года назад +2

      @@giorgichikovani4129 You have to get an ‘app password’ on your Google Account, and use that in your code instead of your normal Gmail password.

    • @giorgichikovani4129
      @giorgichikovani4129 2 года назад

      @@HiranLIVE Tnx

  • @abhinjoby7107
    @abhinjoby7107 2 месяца назад

    For me it's showing System.Net.Sockets.SocketException. I am facing a connection attempt failure. How to fix this?

  • @byte7930
    @byte7930 Год назад

    Exactly what I needed right now! Thanks for your effort!
    If I could place a wish... I worked through your Udemy course which helped me a lot creating my first app for a friend (work in progress). But as I want to run the backend on a Linux machine I'd like to use EntityFramework with MariaDB instead of MS SQL Server. Is there any chance, you could set up a quick tutorial on that? I'd appreciate it with at least one coffee :)

    • @bigggmoustache8868
      @bigggmoustache8868 Год назад

      Seriously, ask chatgpt. If you can find something to guide you alongside it you can probably achieve your goal. It's walked me through so much it's absolutely insane.

    • @samsonmayeem8409
      @samsonmayeem8409 Год назад

      Yes

  • @Al-Quran_channel_
    @Al-Quran_channel_ 7 месяцев назад +1

    La Illaha Ila Alloh

  • @grumpydeveloper69
    @grumpydeveloper69 2 года назад +1

    ANd at @17:08 you use GetSection but _config.GetValue("EmailHost") is much easier to use

  • @attilaguba856
    @attilaguba856 Год назад

    Hi Patrick! Everything is working fine, I have made Contact Us form , but the I have got the same email address for the From and the To objects! I would like to achieve after the user gives the input ( From : user email address ) that will be the sender :
    email.From.Add(MailboxAddress.Parse("user_Input_email"));
    email.To.Add(MailboxAddress.Parse("receiver_EmailAddress"));
    I'm getting emails and etc but the Sender and Receiver are the same email address, ( using gmail ). How Can I fix it?

  • @FernandoZamudioC
    @FernandoZamudioC Год назад

    Hello in the Line
    smtp.Connect("smtp.ethereal.email", 587, MailKit.Security.SecureSocketOptions.StartTls);
    return this error
    SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.
    Any idea ? thank you !