Class MailSenderService
- Namespace
- SunamoMail.Services
- Assembly
- SunamoMail.dll
Email sending service supporting multiple providers.
public class MailSenderService
- Inheritance
-
MailSenderService
- Inherited Members
- Extension Methods
Constructors
MailSenderService(ILogger)
Email sending service supporting multiple providers.
public MailSenderService(ILogger logger)
Parameters
loggerILogger
Methods
SendCentrum(int, From, string, MailMessage)
Sends email via Centrum.cz SMTP server. Note: Centrum now requires SMS verification code for each email sent via SMTP, making this method impractical for automated sending. After one email succeeds, subsequent emails will be blocked.
public bool SendCentrum(int attempts, From from, string to, MailMessage mailMessage)
Parameters
attemptsintNumber of send attempts to make before giving up.
fromFromSender credentials (name, email, password).
tostringRecipient email address.
mailMessageMailMessagePre-configured mail message to send.
Returns
- bool
True if email was sent successfully, false otherwise.
SendSeznam(int, From, string, MailMessage)
Sends email via Seznam.cz SMTP server. Note: This method may timeout at smtpClient.Send with "The operation has timed out." Consider using Seznam Email Pro for better reliability. Alternatively, try using a desktop email client to verify SMTP settings.
public bool SendSeznam(int attempts, From from, string to, MailMessage mailMessage)
Parameters
attemptsintNumber of send attempts to make before giving up.
fromFromSender credentials (name, email, password).
tostringRecipient email address.
mailMessageMailMessagePre-configured mail message to send.
Returns
- bool
True if email was sent successfully, false otherwise.
SendSeznamMailkitWorker(int, From, string, string, string, IEnumerable<string>)
Sends email via Seznam.cz using MailKit library with retry logic. This is an async worker method that attempts to send the email multiple times.
public Task<bool> SendSeznamMailkitWorker(int attempts, From from, string to, string subject, string plainTextBody, IEnumerable<string> attachments)
Parameters
attemptsintNumber of send attempts to make before giving up.
fromFromSender credentials (name, email, password).
tostringRecipient email address.
subjectstringEmail subject line.
plainTextBodystringPlain text email body content.
attachmentsIEnumerable<string>Collection of file paths to attach to the email.
Returns
SendSeznamMailkitWorker(int, From, string, string, string, IEnumerable<string>, IEnumerable<string>?)
Sends email via Seznam.cz using MailKit library with retry logic and optional CC recipients.
public Task<bool> SendSeznamMailkitWorker(int attempts, From from, string to, string subject, string plainTextBody, IEnumerable<string> attachments, IEnumerable<string>? cc)
Parameters
attemptsintNumber of send attempts to make before giving up.
fromFromSender credentials (name, email, password).
tostringRecipient email address.
subjectstringEmail subject line.
plainTextBodystringPlain text email body content.
attachmentsIEnumerable<string>Collection of file paths to attach to the email.
ccIEnumerable<string>Optional collection of CC email addresses.