This article is a mirror article of machine translation, please click here to jump to the original article.

View: 44792|Reply: 6

[Source] .NET/C# MailKit Tutorial for Sending Mail [with Source Code]

[Copy link]
Posted on 2021-9-2 09:27:49 | | | |
Application system sending emails is a basic function, almost all website applications will need to send emails, such as: email registration verification, push reminder messages, sending password recovery links, etc.

Using Microsoft's own SmtpClient class can help us send emails, but now it has been marked as obsolete, and Microsoft has not given its own alternatives, so it is recommended to use third-party libraries, as shown in the figure below:

Allow applications to use Simple Mail Transfer Protocol (SMTP) to send email. The SmtpClient type is now obsolete.

The SmtpClient class is not recommended for new development, as SmtpClient does not support many modern protocols. Use MailKit or another library instead.




Link:The hyperlink login is visible.

Recap of sending emails with Microsoft SMTPclient:

c# SmtpClient sends the email source code
https://www.itsvse.com/thread-2567-1-1.html

.net/c# send mail via html templates
https://www.itsvse.com/thread-4424-1-1.html

C# implements the function of sending emails
https://www.itsvse.com/thread-2596-1-1.html
Sending emails using Microsoft's smtpclient may result in an error:Authentication failed, however, both the account and password are correct

This article uses Microsoft's third-party library MailKit to send emails, first, use nuget to install with the following command:

The sending code is as follows:

I wrote a winform applet to facilitate testing on the server, as shown in the figure below:



SmtpHost= "smtp.exmail.qq.com",
EnableSsl =true,
Password= "pass123456",
Port= 587,
UserName= "itsvse@baidu.com"

Try sending an email as shown below:



Attach the source code and procedure:

Tourists, if you want to see the hidden content of this post, pleaseReply






Previous:The use of tuples in Java
Next:Install nginx service with CentOS source code
Posted on 2021-9-2 17:30:02 |
This prostitution wave is just used.
Posted on 2021-9-19 19:32:49 |
Learn to learn...
 Landlord| Posted on 2021-11-4 14:39:25 |
Posted on 2021-11-5 16:56:31 |
Well, this can be prostituted
Posted on 2021-12-3 14:11:33 |
Bao, you are great
Posted on 2024-1-8 16:02:44 |
Just used. Look
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com