Gmailr formatting

Hi all,

I'm basically wondering how to make a gmailr message look like it was sent from gmail.com. Currently the font is fixed width, the from field contains just the address, and the signature is missing. Is there a way to change those things? Thanks!

Can you show us a mininal reprex of the gmailr::mime()? I haven't had your issue before.

I'm suspecting that you might be creating your gmailr emails with text_body
The gmailr function html_body() function accepts html formatting.

Hi @EconomiCurtis, thanks for the suggestion. Replacing text_body with html_body does replace fixed-width font with normal-looking font, but when I send this with send_message, I still don't get the gmail signature coming through, and neither the gmail-specified from name nor the name I specify in from; instead the address itself appears in the from field. Any ideas? Thanks.

suppressPackageStartupMessages(library(gmailr))
mime() %>%
  from("My Fancy Name") %>% 
  subject("Hi friend!") %>%
  html_body("This is the substance of the message.") 
#> $parts
#> $parts[[1]]
#> NULL
#> 
#> $parts[[2]]
#> $parts
#> list()
#> 
#> $header
#> $header$`MIME-Version`
#> [1] "1.0"
#> 
#> $header$Date
#> [1] "Fri, 29 Jun 2018 18:49:34 GMT"
#> 
#> 
#> $body
#> [1] "This is the substance of the message."
#> 
#> $attr
#> $attr$content_type
#> [1] "text/html"
#> 
#> $attr$charset
#> [1] "utf-8"
#> 
#> $attr$encoding
#> [1] "base64"
#> 
#> 
#> attr(,"class")
#> [1] "mime"
#> 
#> 
#> $header
#> $header$`MIME-Version`
#> [1] "1.0"
#> 
#> $header$Date
#> [1] "Fri, 29 Jun 2018 18:49:34 GMT"
#> 
#> $header$From
#> [1] "My Fancy Name"
#> 
#> $header$Subject
#> [1] "Hi friend!"
#> 
#> 
#> $body
#> NULL
#> 
#> $attr
#> NULL
#> 
#> attr(,"class")
#> [1] "mime"

Created on 2018-06-29 by the reprex package (v0.2.0).

From my experience using the gmailr package, there aren't helper functions that would help you achieve this. I'd say your best bet is to hit the gmail API (if that's even a thing) docs.

I also don't get my gmail signature when sending an email via gmailr either. But that wasn't surprising. For example, when I send a gmail-email from my phone's email application, the signature is the one I set up on the phone, not the gmail signature. I think the I'd only expect that gmail signature when using a gmail application. Also, knowing that your gmail signature isn't included in gmailr email, you can obviously just include it yourself in the mine.

I had success with to and from names like so (obviously replacing the from email with the correct address),

email <- mime() %>%
  to("'Mom' <mother@gmail.com>") %>%
  from("'ME' <fakus.namus@gmail.com>") %>%
  subject("Gmailr is a very handy package!") %>% 
  html_body("And I sure do <b>like it</b>.") 
2 Likes

Thanks, Curtis. That trick for the from field works for me, though the single quotes come through and are unnecessary, so I use from("ME <fakus.namus@gmail.com>"). The signature part makes sense, and right, it's easy enough to add manually. Thanks for the help.

1 Like