Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sendmailR: Submit encoded message to local SMTP server

I need your help in order to send email message that includes text in Greek, from within R, using the function sendmail {sendmailR}.

I tried using the function iconv, like that but it didn't work

subject <- iconv("text in greek", to = "CP1253")
sendmail(from, to, subject, msg, control=list(smtpServer="blabla"))

The mail arrives immediately but the greek characters are unreadable. Any ideas?

EDIT

Another question that came up: The second argument to accepts one recipient. What if want to send it to more than one? (I think 'll try sapply ing the sendmail function to a vector of recipients) - Ok, that worked. However, I'm not completely satisfied because each one of the recipients has no way to know who else has received the message.

like image 516
George Dontas Avatar asked Aug 20 '10 07:08

George Dontas


1 Answers

Mail client won't be able to understand any encoding without Content-Type: charset=..., so you must add it:

msg<-iconv("text in greek", to = "utf8");
sendmail(from, to, subject, msg, 
control=list(smtpServer="blabla"),
headers=list("Content-Type"="text/plain; charset=UTF-8; format=flowed")
);

that is for UTF8 (which I believe should be used), for CP1253:

msg<-iconv("text in greek", to = "CP1253");
sendmail(from, to, subject, msg, 
control=list(smtpServer="blabla"),
headers=list("Content-Type"="text/plain; charset=CP1253; format=flowed")
);

multisend by hidden copies can also be done with header magick, still I think sapply loop is a better idea -- then the user will see that the mail was send directly to her/himself.

like image 185
mbq Avatar answered Nov 03 '22 22:11

mbq