A simple self-hosted email sending HTTP API service using SMTP.
- Somehow the SMTP connections are blocked by ISP or the SMTP server, but a third server works.
- Centerized email sending configuration.
Edit appsettings.json
, add STMP account configurations:
{
"Urls": "http://127.0.0.1:8080",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Mail": {
"Accounts": [
{
"Token": "should_be_random_generated",
"From": "sender@example.com",
"FromName": "The Sender",
"Host": "smtp.exmail.qq.com",
"Port": 465,
"Tls": true,
"Username": "sender@example.com",
"Password": ""
}
]
}
}
git clone https://github.com/lideming/mailservice.git
cd mailservice
dotnet run -c Release
docker run -d -v /PATH/TO/SETTINGS.json:/app/appsettings.json yuuza/mailservice
POST /api/mail
with JSON body:
interface Mail {
fromName: string;
to: string;
toName: string;
subject: string;
body: string;
bodyType:
| "text" // "text/plain"
| "html" // "text/html"
| string // any MIME type
;
}