{emayili} Support for ZeptoMail

[This article was first published on R - datawookie, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 = "[email protected]",
  from = "[email protected]",
  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.

To leave a comment for the author, please follow the link and comment on their blog: R - datawookie.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)