Skip to content

Commit 29ff4e7

Browse files
committed
fix: don't strip names from engine options
Fixes #14
1 parent 692be38 commit 29ff4e7

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

R/sendmailR.r

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,17 @@
146146
msg, verbose = FALSE) {
147147
# Check if curl is installed.
148148
if (!requireNamespace("curl", quietly = TRUE)) {
149-
stop("sendmail: engine = \"curl\" needs the curl package installed.
149+
stop("sendmail: engine = \"curl\" needs the curl package installed.
150150
Please run: install.packages(\"curl\")", call. = FALSE)
151151
}
152152

153153
stopifnot(is.character(headers$From))
154154

155155
# remove options to prevent multiple matching arguments
156-
curlopts <- setdiff(curlopts,
157-
c("smtp_server", "mail_from", "mail_rcpt",
158-
"message", "verbose"))
156+
valid_options <- setdiff(
157+
names(curlopts),
158+
c("smtp_server", "mail_from", "mail_rcpt", "message", "verbose"))
159+
curlopts <- curlopts[valid_options]
159160
# Default to force
160161
if (is.null(curlopts$use_ssl)) curlopts$use_ssl <- "force"
161162

@@ -170,15 +171,14 @@
170171
close(sock)
171172
unlink(sock)
172173

173-
do.call(curl::send_mail,
174-
c(list(
175-
mail_from = from,
176-
mail_rcpt = to,
177-
message = msg,
178-
verbose = verbose,
179-
smtp_server = smtp_server),
180-
curlopts)
181-
)
174+
args <- c(list(
175+
mail_from = from,
176+
mail_rcpt = to,
177+
message = msg,
178+
verbose = verbose,
179+
smtp_server = smtp_server),
180+
curlopts)
181+
do.call(curl::send_mail, args)
182182
}
183183

184184
##' Simplistic sendmail utility for R. Uses SMTP to submit a message

0 commit comments

Comments
 (0)