Skip to content

Enhancement: Support for Vector or List of Emails for Multiple Recipients#197

Closed
nikitoshina wants to merge 2 commits intor-lib:mainfrom
nikitoshina:patch-1
Closed

Enhancement: Support for Vector or List of Emails for Multiple Recipients#197
nikitoshina wants to merge 2 commits intor-lib:mainfrom
nikitoshina:patch-1

Conversation

@nikitoshina
Copy link

This pull request introduces the ability to pass a vector or list of emails to the function, enabling the creation of an email with multiple recipients. This feature addresses an issue encountered by our team, where there was an assumption that the function could naturally handle a vector/list of emails for sending to multiple recipients. A thorough search revealed no documentation on how to achieve this, indicating a gap in usability for users unfamiliar with the underlying mechanics of the function.

The addition of this feature simplifies the process of including multiple recipients, CCs, and BCCs, making it more accessible and user-friendly, especially for those not versed in the function's inner workings.

@nikitoshina nikitoshina requested a review from jennybc as a code owner February 22, 2024 00:12
return(x$header$To)
}
if (length(val) > 1) {
x$header$To <- paste(val, collapse=",")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
x$header$To <- paste(val, collapse=",")
x$header$To <- paste(val, collapse = ",")

return(x$header$Cc)
}
if (length(val) > 1) {
x$header$Cc <- paste(val, collapse=",")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
x$header$Cc <- paste(val, collapse=",")
x$header$Cc <- paste(val, collapse = ",")

Comment on lines +87 to +88
x$header$Bcc <- paste(val, collapse=",")
return(x)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
x$header$Bcc <- paste(val, collapse=",")
return(x)
x$header$Bcc <- paste(val, collapse = ",")
return(x)

@jennybc jennybc closed this in 9630af7 Nov 4, 2025
@jennybc
Copy link
Member

jennybc commented Nov 4, 2025

Thanks and sorry this sat for so long! Once I reviewed it, I found tests suggesting that multiple recipients already works for To, Cc, and Bcc:

rv <- gm_to(msg, c("adam@ali.as", "another@ali.as", "bob@ali.as"))
expect_equal(
header_encode(rv$header$To),
"adam@ali.as, another@ali.as, bob@ali.as",
label = "to (multiple) sets To header"
)
rv <- gm_cc(msg, c("adam@ali.as", "another@ali.as", "bob@ali.as"))
expect_equal(
header_encode(rv$header$Cc),
"adam@ali.as, another@ali.as, bob@ali.as",
label = "cc (multiple) sets To header"
)
rv <- gm_bcc(msg, c("adam@ali.as", "another@ali.as", "bob@ali.as"))
expect_equal(
header_encode(rv$header$Bcc),
"adam@ali.as, another@ali.as, bob@ali.as",
label = "bcc (multiple) sets To header"
)

And documentation also indicating that a vector can be provided to gm_to(val =) and friends:

#' @param val the value to set, can be a vector, in which case the values will be joined by ", ".

I also manually tested the functionality and it already works. So I added an example to hopefully make this more discoverable, but we don't need to change the code as per this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants