I have successfully managed to implement the sendmailR function to send one message to one recipient.
Do you know if it is possible to send that same message to multiple recipients within the function? A form of CC'ing?
If not I think the only way is to loop round on a variable, which would normally be okay but for my current code would result with a loop within a loop and make things fairly and hopefully unnecessary complex
I cant see anything in the documentation that would appear to indicate functionality like this --> http://cran.r-project.org/web/packages/sendmailR/sendmailR.pdf
Thanks for any help, I will keep testing to see if there is a work around inm the meantime!
In the source code for sendmail
it states...
if (length(to) != 1)
stop("'to' must be a single address.")
So this leaves you with several options (all of which are loops).The execution time of a loop compared to sending the email will be negligible. A couple of options are:
Use Vectorize
to vectorise the to
argument of sendmail
, allowing you to supply a character vector of email addresses to send to...
sendmailV <- Vectorize( sendmail , vectorize.args = "to" )
emails <- c( "[email protected]" , "[email protected]" )
sendmailV( from = "[email protected]" , to = emails )
Using sapply
to iterate over the a character vector of email addresses applying the sendmail
function each time...
sapply( emails , function(x) sendmail( to = "[email protected]" , to = x ) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With