Skip to content

Commit 1dbf4cc

Browse files
committed
docs(mail): document the SMTP sender (AddMailSender / SendAsync)
1 parent 2495743 commit 1dbf4cc

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/SquidStd.Mail.Abstractions/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ dotnet add package SquidStd.Mail.Abstractions
2828
| `MailReceivedEvent` | Published on the event bus per new message. |
2929
| `IMailReader` | Fetches new messages from a mailbox. |
3030
| `MailOptions` | Host/port/credentials, protocol, polling and fetch options. |
31+
| `IMailSender` | Sends outbound email. |
32+
| `OutgoingMailMessage` | An email to send (recipients, subject, bodies, attachments). |
33+
| `SmtpOptions` | SMTP host/port/SSL/credentials and a default sender. |
34+
| `MailSentEvent` / `MailSendFailedEvent` | Published on the event bus on send success/failure. |
3135

3236
## License
3337

src/SquidStd.Mail.MailKit/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,36 @@ container.AddMail(new MailOptions
4444
Listen with an `IAsyncEventListener<MailReceivedEvent>` registered on the `IEventBus`. IMAP marks messages
4545
`\Seen` after fetch (configurable); POP3 dedups by UIDL and can delete after download.
4646

47+
## Sending (SMTP)
48+
49+
```csharp
50+
using DryIoc;
51+
using SquidStd.Mail.Abstractions.Data;
52+
using SquidStd.Mail.Abstractions.Data.Config;
53+
using SquidStd.Mail.Abstractions.Interfaces;
54+
using SquidStd.Mail.MailKit.Extensions;
55+
56+
container.AddMailSender(new SmtpOptions
57+
{
58+
Host = "smtp.example.com",
59+
Port = 587,
60+
UseSsl = false,
61+
Username = "user@example.com",
62+
Password = "secret",
63+
DefaultFrom = new MailAddress("App", "app@example.com")
64+
});
65+
66+
var sender = container.Resolve<IMailSender>();
67+
await sender.SendAsync(new OutgoingMailMessage
68+
{
69+
To = [new MailAddress("Bob", "bob@example.com")],
70+
Subject = "Welcome",
71+
HtmlBody = "<p>Hello!</p>"
72+
});
73+
```
74+
75+
`MailSentEvent` / `MailSendFailedEvent` are published on the `IEventBus`; failures throw `MailSendException`.
76+
4777
## License
4878

4979
MIT — part of [SquidStd](https://github.com/tgiachi/squid-std).

0 commit comments

Comments
 (0)