eidam / cf-workers-status-page

Monitor your websites, showcase status including daily history, and get Slack/Telegram/Discord notification whenever your website status changes. Using Cloudflare Workers, CRON Triggers, and KV storage.
https://status-page.eidam.dev
MIT License
2.19k stars 1.32k forks source link

Setup SMTP for Incidents #98

Open PBhadoo opened 1 year ago

PBhadoo commented 1 year ago

How can we setup SMTP for receiving email for incidents.

iambenmitchell commented 1 year ago

Last I checked, CF workers do not have the ability to make or receive SMTP requests. You can use an API like mailgun or your own to send and receive mail though.

Could be wrong, I haven't checked in a few months so maybe they added something recently?

OnlyFor commented 1 year ago

Maybe it's possible to use this to send email?

https://blog.cloudflare.com/sending-email-from-workers-with-mailchannels/

yswtrue commented 11 months ago

Hope for smtp too

gaborcsardi commented 2 months ago

FWIW, it is not too hard to add email notifications, it goes like this: https://github.com/eidam/cf-workers-status-page/compare/main...gaborcsardi:cf-workers-status-page:main (Ignore the config and logo changes.)

You can only send emails from a domain that you control, and you need to add a TXT record to that domain's DNS, which looks like this:

_mailchannels TXT v=mc1 cfid=<myhost>.workers.dev

where <myhost> is your workers subdomain (it is listed on the right side of the "Workers & Pages" page.

You'd probably also want a secret or a config option for the sender's email.

Great project, btw!

EDIT: two possible gotchas. First, some mail servers like gmail.com require at least an SPF record, see the example at https://medium.com/@tristantrommer/how-to-send-free-transactional-emails-with-worker-mailchannels-via-cloudflare-workers-818b787b33f9

Second, that SPF record might interfere with an existing one, e.g. if you also set up email forwarding on cloudflare. Then you need both mail servers in the SPF record, e.g.

@ TXT "v=spf1 include:_spf.mx.cloudflare.net include:relay.mailchannels.net ~all"