How to send HTML email using R

This is possible, cf https://stackoverflow.com/a/21930556/448145 Just add:

msg <- mime_part(message)
msg[["headers"]][["Content-Type"]] <- "text/html"
sendmail(from, to, subject, msg = msg, ...)

sendmailR cannot do this because it is hard-coded to send the message part out as text. If you look at the packages source, line 38 of sendmail.R is the following:

writeLines("Content-Type: text/plain; format=flowed\r\n", sock, sep="\r\n")

Change that to

writeLines("Content-Type: text/html; format=flowed\r\n", sock, sep="\r\n")

like you tried to do through the options and it will work.

Update: sendmailR now allows html emails (see Karl's answer below and https://stackoverflow.com/a/21930556/448145).

Tags:

Html

Email

R