| | | 1 | | using ArturRios.Output; |
| | | 2 | | |
| | | 3 | | namespace ArturRios.Messaging.Email; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Defines an e-mail delivery service. |
| | | 7 | | /// </summary> |
| | | 8 | | public interface IEmailService |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Sends a plain text e-mail. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="to">Recipient e-mail address.</param> |
| | | 14 | | /// <param name="subject">Subject line of the e-mail.</param> |
| | | 15 | | /// <param name="body">Plain text body of the e-mail.</param> |
| | | 16 | | /// <returns>A <see cref="ProcessOutput"/> describing whether the e-mail was accepted for delivery.</returns> |
| | | 17 | | Task<ProcessOutput> SendEmailAsync(string to, string subject, string body); |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Sends a plain text e-mail, observing <paramref name="cancellationToken"/>. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="to">Recipient e-mail address.</param> |
| | | 23 | | /// <param name="subject">Subject line of the e-mail.</param> |
| | | 24 | | /// <param name="body">Plain text body of the e-mail.</param> |
| | | 25 | | /// <param name="cancellationToken">Cancels the send.</param> |
| | | 26 | | /// <returns>A <see cref="ProcessOutput"/> describing whether the e-mail was accepted for delivery.</returns> |
| | | 27 | | /// <exception cref="OperationCanceledException"><paramref name="cancellationToken"/> was canceled.</exception> |
| | | 28 | | /// <remarks> |
| | | 29 | | /// The default implementation, for implementations written before this overload existed, only checks the token |
| | | 30 | | /// before delegating to <see cref="SendEmailAsync(string, string, string)"/>. <see cref="MailgunEmailService"/> |
| | | 31 | | /// passes it on to the HTTP request. |
| | | 32 | | /// </remarks> |
| | | 33 | | Task<ProcessOutput> SendEmailAsync(string to, string subject, string body, CancellationToken cancellationToken) |
| | 2 | 34 | | => cancellationToken.IsCancellationRequested |
| | 2 | 35 | | ? Task.FromCanceled<ProcessOutput>(cancellationToken) |
| | 2 | 36 | | : SendEmailAsync(to, subject, body); |
| | | 37 | | } |