EmailSenderSMTP
Описание
This nuget package is designed to better interact with SmtpClient
Языки
- C#100%
EmailSender.SMTP
Introduction
This project is a Nuget-package.
It is needed in order to make it easier to work with the standard SmtpClient class in .NET CORE 7/8.
Content:
- Introduction
- Content
- Supported MailServices
- SenderSMTP & its constructor
- Create Text/HTML MailMessage
- Send MailMessage
- Other Methods
Supported MailServices
MailService - enum, which contains the value of SMTP-servers that are supported by this library. Some SMTP-servers will be checked in the future, but have already been added for selection. MailServic enum values:
| Value | SMTP Server | Has it been checked? |
|---|---|---|
| MailRu | mail.ru | checked |
| GoogleCom | google.com | checked |
| YandexRu | yandex.ru | not checked |
| PochtaRu | pochta.ru | not checked |
| RamblerRu | rambler.ru | not checked |
SenderSMTP & its constructor
SenderSMTP is a class that configures the SmtpClient class itself when its constructor is called.NET CORE.
In the constructor, this class accepts:
- (required) MailService - one of the MailService enum values (enum MailService)
- (required) emailFrom - email address from which emails will be sent (string)
- (required) pass - password for applications from the email address. from which emails will be sent (string)
- (optional) nameAuthor -the name of the sender to be displayed in the email, it can be specified separately for each message (string)
- (optional) emailsPerMinutes - number of emails that can be sent in 1 minute, it is recommended to leave the default value (int)
Create Text/HTML MailMessage
There are two methods for creating messages in the library:
Both methods take the same arguments:
- (required) emailTo - the email address of the recipient of the help (string)
- (optional) name - the name of the sender, which will be displayed in the email message. (string)
- (optional) subject - title email message (string)
- (optional) bodyHtml/bodyText - The content of the email message (string)
Below is an example of creating messages with an HTML or Text body.
Example:
Send MailMessage
Each method for sending messages has its asynchronous version, which differs only in that the postfix 'Async' is added to the end of its name. It is quite simple to work with all the methods, so next there will be only examples with signatures.
Other Methods
This library contains not only methods for sending a single message, but also methods for sending a single message to multiple addresses, or multiple messages.
SendMailToAddresses()
is a method for sending a single message to multiple addresses.
Example:
SendMailsToAddresses()
is a method for sending a multiple messages to multiple addresses.