rpremraj / mailR

A utility to send emails from the R programming environment
http://rpremraj.github.io/mailR/
190 stars 57 forks source link

send.mail fails to recognize multiple recipients #73

Open trespitt opened 6 years ago

trespitt commented 6 years ago

My script send an email to three different recipients. During testing and the first month of deployment, it worked every time. Recently, send.mail only sends the email to the third and final recipient. For instance: ...to=c('arb1@gmail.com','arb2@gmail.com','my_email@gmail.com')... So, I want to 'copy' myself on the emails - this works, but the other two recipients are ignored. This problem has occurred across multiple distinct scripts (in different working directories). However, some scripts have yet to exhibit the problem.

You can see that 'my_email@gmail.com' is both the singular argument to the from parameter, and the third element in the list supplied to the to argument. I hope this isn't the problem (because I don't want to have to use a secondary email address to monitor).

The first time this happened, I fixed it by doing something dumb - basically moving the function which contains send.mail to a different location in the file and changing a few lines or characters of style (no actual change in the function). I tried this on the next script that broke, and it didn't work.

Here's the function itself (which worked perfectly for a while). You can see that I specify my email address literally in the to argument but read it from the obfuscation object in the from argument. Previously it was logins$user for both; changing it didn't fix the problem. Also, the domain I'm sending to isn't really gmail but rather a company's domain that is hosted by gmail, if that matters.

send.email<-function(email.subject,email.body){ source('cryptRead.R') conf<-'CONFIDENTIALITY NOTICE...' email.body<-paste0(email.body,'\n\n',conf) send.mail(from=logins$user, to=c('arb1@gmail.com','arb2@gmail.com','my_email@gmail.com'), subject=email.subject, body=email.body, smtp=list(host.name='smtp.gmail.com', port=465, user.name=logins$user, passwd=logins$pwd, ssl=TRUE), authenticate=TRUE,send=TRUE,debug=TRUE) }

rpremraj commented 6 years ago

Very strange behavior. To help me investigate, can you share your session info?

trespitt commented 6 years ago

what information are you looking for, do you just mean .RData? I don't think this will be helpful. After submitting this report, I implemented a simple work-around (which will moot the value of .RData to you, I believe) -- only specify one unique recipient in to= and add multiple recipients in cc=. I have yet to see a failure with this method