Skip to content

Commit

Permalink
subject enc now part of sendmailR
Browse files Browse the repository at this point in the history
  • Loading branch information
areedv committed Dec 13, 2022
1 parent 746c117 commit 5d1262d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rapbase
Type: Package
Title: Base Functions and Resources for Rapporteket
Version: 1.23.1
Version: 1.23.1.9000
Authors@R: c(
person(given = "Are",
family = "Edvardsen",
Expand All @@ -24,7 +24,6 @@ LazyData: true
Depends:
R (>= 3.5.0)
Imports:
base64enc,
bookdown,
DBI,
digest,
Expand Down
17 changes: 2 additions & 15 deletions R/sendEmail.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#' address, SMTP server url and port number
#' @param to Character vector containing email addresses. May also contain
#' full names like '\code{Jane Doe <janed@nowhere.com>}'
#' @param subject Character string providing email subject. The string is
#' converted within this function to conform to RFC 1342
#' @param subject Character string providing email subject.
#' @param text Character string providing the plain email text
#' @param attFile Character string providing the full file path to an
#' attachment. Default is NULL in which case no attachment is made
Expand All @@ -21,24 +20,12 @@ sendEmail <- function(conf, to, subject, text, attFile = NULL) {
if (!is.null(attFile)) {
stopifnot(file.exists(attFile))
}
# nocov start

# apply RFC 1342 on headers (i.e. subject)
charset <- "=?UTF-8?"
enc <- "B?"
headPost <- "?="
# nocov start

from <- conf$network$sender
# escape spaces (e.g. when full name is added to <email>)
to <- gsub(" ", "\\ ", to, fixed = TRUE)
# Subject is a header field, hence non-ascii to be base64 encoded
# Header lines must be 76 chars or less and split by a space
# and contain consistent encoded-word(s)
subject <- charToRaw(subject)
subject <- base64enc::base64encode(subject, linewidth = 63)
subject <- paste(paste0(charset, enc, subject, headPost),
collapse = " "
)

if (is.null(attFile)) {
body <- list(text)
Expand Down
3 changes: 1 addition & 2 deletions man/sendEmail.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d1262d

Please sign in to comment.