By default, Blastula encloses RMarkdown emails with a gray border. This looks wrong on Gmail, as Gmail already adds a gray border to emails, boxing all your rmarkdown mails with a white box inside a gray box, inside a another white box inside yer another gray box.
The code I used to produce this email is as follows:
informe_html <- readr::read_file("html_email.html")
email <- compose_email(body = md(informe_html))
My html file has no borders at all, just the dark grey background over a white background. The remaining light gray, white and light gray borders are added by Blastula.
The email
object produced from compose_email()
contains HTML, so you can use string manipulation to change the appearance of the email. When you inspect the HTML code, the grey looks like it is coming from the <body>
tag, which has the style attribute: background-color:#f6f6f6
. Removing this tag should remove the grey border around the message.
blastula_message
objects seem to have two versions of the HTML for the message:
html_str
: The raw HTML stored as a character string.html_html
: The HTML stored as a html
object.The first is what actually gets sent when you use smtp_send()
and the second seems to be what you see when you preview the message via print(email)
. To be safe you can remove the background-color
attribute from both:
email$html_str <- sub(
x = email$html_str,
pattern = "background-color:#f6f6f6(;)",
replacement = "")
email$html_html <- sub(
x = email$html_html,
pattern = "background-color:#f6f6f6(;)",
replacement = "")
The (;)
in the pattern is in case background-color
isn't the only style attribute for <body>
.
When you preview email
the grey border should now be gone as the background of the mail will now be transparent.