r-lib / gmailr

Access the Gmail RESTful API from R.
https://gmailr.r-lib.org
Other
229 stars 56 forks source link

Add an example setting the from field? #134

Open maelle opened 4 years ago

maelle commented 4 years ago

In the vignette about sending emails, could there be an example setting the From field to a name and an address as in this community forum post?

I.e. e.g.

text_msg <- gm_mime() %>%
  gm_to("james.f.hester@gmail.com") %>%
  gm_from("Gmailr Fan <me@somewhere.com>") %>%
  gm_text_body("Gmailr is a very handy package!")
jimhester commented 4 years ago

Sounds like a good idea to me!

jennybc commented 1 year ago

Very related to #171

Yes, this sort of code results in a display name appearing if and only if the gm_from() address is actually the sending address (see gm_profile()):

text_msg <- gm_mime() %>%
  gm_to("alice@example.com") %>%
  gm_from("Gmailr Fan <bob@example.com>") %>%
  gm_text_body("hello!")

If you aren't actually auth'ed as bob@example.com then the gm_from() information is basically ignored.

So this shows how to do this on the fly, whereas #171 is about configuring settings or just having a better default.