Open PBhadoo opened 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?
Maybe it's possible to use this to send email?
https://blog.cloudflare.com/sending-email-from-workers-with-mailchannels/
Hope for smtp too
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"
How can we setup SMTP for receiving email for incidents.