Sends immediately. To produce a Gmail draft for review instead, use
mc_draft().
Usage
mc_send(
path = NULL,
to,
subject,
cc = NULL,
bcc = NULL,
from = default_from(),
thread_id = NULL,
to_self = FALSE,
sig = TRUE,
sig_path = NULL,
attachments = NULL,
labels = NULL,
labels_create = TRUE,
html = NULL,
send_at = NULL,
scheduler = c("callr", "auto", "launchd", "at")
)Arguments
- path
Path to the markdown draft file. Passed to
mc_md_render().- to
Recipient email address (character string or vector).
- subject
Email subject line.
- cc
Optional CC recipients (character vector). Default
NULL.- bcc
Optional BCC recipients (character vector). Default
NULL.- from
Sender address. Default uses
getOption("mc.from"), then theMC_FROMenvironment variable. Errors if neither is set.- thread_id
Gmail thread ID to reply into. Default
NULL(new thread). Usemc_thread_find()to look up thread IDs.- to_self
Logical. If
TRUE, overridetowithfromand dropcc,bccandthread_id, so the message reaches nobody but the sender. DefaultFALSE. This caps who receives the message; it does not stop the send. Usemc_draft()if you do not want a message delivered at all.- sig
Logical. Append signature? Passed to
mc_md_render(). DefaultTRUE.- sig_path
Path to a custom signature HTML file. Default
NULLuses the bundled New Graph signature. Passed tomc_md_render(). Ignored whensig = FALSEor whenhtmlis provided.- attachments
Optional character vector of file paths to attach. Each file is attached via
gmailr::gm_attach_file(). DefaultNULL.- labels
Optional character vector of Gmail label names to apply to the resulting thread. Applied via
mc_thread_modify()after a successful send.- labels_create
Logical. When
TRUE(default), missing user labels inlabelsare auto-created viamc_label_ensure().- html
Optional pre-rendered HTML body. If provided,
pathis ignored and this HTML is used directly.- send_at
Schedule the email for later. Either a
POSIXctdatetime or a numeric number of minutes from now. DefaultNULL(send now). Scheduling is inherently a send, which is why it lives here and not onmc_draft().- scheduler
Backend for scheduled send. One of
"callr"(default),"auto"(OS-native:launchdon macOS,aton Linux),"launchd", or"at". Ignored whensend_atisNULL.
Value
The Gmail thread ID of the sent message, invisibly. When send_at
is set, returns a backend-specific scheduler handle invisibly instead.
Details
The verb lives in the function name deliberately. An earlier API selected
send-vs-draft with a draft argument, which meant one character separated a
reversible act from an irreversible one — and did, once, deliver a message to
external recipients when a draft was intended. There is no draft argument
here; sending is named, not configured (#39).
Authenticates automatically if no active Gmail session is detected.
See also
mc_draft() to create a draft, mc_md_send() to send from
frontmatter.
Examples
if (FALSE) { # \dontrun{
mc_send("communications/newsletter.md",
to = "someone@example.com",
subject = "Spring newsletter")
# Check the rendering in a real inbox without involving anyone else
mc_send("communications/newsletter.md",
to = "someone@example.com",
subject = "Spring newsletter",
to_self = TRUE)
# Reply into an existing thread
mc_send("communications/reply.md",
to = "someone@example.com",
subject = "Re: Spring newsletter",
thread_id = "19c05f0a98188c91")
} # }
