{emayili} Support for ZeptoMail

The {emayili} package already has adapters which make it simple to send email via a variety of services. I have just added an adapter for the ZeptoMail transactional email service. The adapter is available in {emayili} version 0.7.13.

Account Setup

Before you can send emails via ZeptoMail you will need to validate your domain. Add entries to your DNS configuration for

  • SPF (if you have an existing SPF record, replace it with the new one)
  • DKIM and
  • CNAME.

You’ll also need to specify an email address which will be used for bounced messages.

Sending Mail via ZeptoMail

You can use either an API or an SMTP server to send messages via ZeptoMail. We’ll be using SMTP. The zeptomail() function is a specialised wrapper for the server() function. It requires only a password. I store my password in an environment variable called ZEPTOMAIL_PASSWORD.

Load {emayili} and create a ZeptoMail SMTP server object.

library(emayili)

ZEPTOMAIL_PASSWORD <- Sys.getenv("ZEPTOMAIL_PASSWORD")

smtp <- zeptomail(ZEPTOMAIL_PASSWORD)

Now create a message object. The address specified in the From field needs to be for the same domain that was registered with ZeptoMail (see Account Setup above).

msg <- envelope(
  to = "alice@gmail.com",
  from = "info@fathomdata.dev",
  subject = "Test"
) %>%
  text("Hello there!")

Now send that message.

smtp(msg, verbose = TRUE)

It should be delivered promptly.

If you are using other email services and you’d like them to be better supported by {emayili}, just create an issue and I’ll get it sorted.