Interface IEmailSenderGastroSky
- Namespace
- GastroSky.Services.EmailServices.EmailSender
- Assembly
- GastroSky.dll
Interface for sending emails asynchronously.
public interface IEmailSenderGastroSky
Methods
SendEmailAsync(IEmail)
Method that sends Email Async that accepts a parameter of type IEmail
Task<bool> SendEmailAsync(IEmail email)
Parameters
Returns
SendEmailAsync(string, string, string)
Sends a plain-text-only email to a single recipient.
Only use for testing or internal use: html+text variant is much more professional.
The "from" parameter shall be set automatically by the implementing class.
Task<bool> SendEmailAsync(string subject, string text, string to)
Parameters
subjectstringThe email's subject.
textstringThe email's text body.
tostringThe recipient's email address. Please ensure this is valid!
Returns
SendEmailAsync(string, string, string, string, string?, IReadOnlyCollection<string>?, IReadOnlyCollection<string>?, IReadOnlyCollection<string>?, IReadOnlyCollection<MailAttachment>?)
Sends an email that contains both a text and html variant. This is the most common approach.
NOTE: even though it is possible to add additional recipients (and CC) it is NOT recommended!
Sending an email to multiple addresses allows all the recipients to see each others' full email addresses.
For the sake of privacy it's recommended to send multiple mails out to single recipients instead (or use BCC, yeah...)
Task<bool> SendEmailAsync(string from, string to, string subject, string html, string? replyTo = null, IReadOnlyCollection<string>? additionalRecipients = null, IReadOnlyCollection<string>? cc = null, IReadOnlyCollection<string>? bcc = null, IReadOnlyCollection<MailAttachment>? attachments = null)
Parameters
fromstringThe sender's email address. This can be a raw email address or in the format "Justin Sider <justin.sider@domain.com>".
tostringThe recipient email address.
subjectstringThe mail's subject.
htmlstringThe html email body.
replyTostringA custom reply-to address. Can be omitted.
additionalRecipientsIReadOnlyCollection<string>Any additional, directly addressed recipients. IMPORTANT: read the doc summary to find out why this is a very bad idea. Use for testing or internal use ONLY!!!
ccIReadOnlyCollection<string>Carbon copy list.
bccIReadOnlyCollection<string>Blind carbon copy list.
attachmentsIReadOnlyCollection<MailAttachment>Any email attachments.
Returns
SendEmailAsyncWithReturnSentEmail(IEmail)
Method that sends Email Async that accepts a parameter of type IEmail and returns the SentEmail
Task<SentEmail?> SendEmailAsyncWithReturnSentEmail(IEmail email)