Geo*_*tas 6 email encoding smtp r
我需要你的帮助才能使用函数sendmail {sendmailR}从R中发送包含希腊语文本的电子邮件.
我尝试使用这个功能iconv,但它没有用
subject <- iconv("text in greek", to = "CP1253")
sendmail(from, to, subject, msg, control=list(smtpServer="blabla"))
Run Code Online (Sandbox Code Playgroud)
邮件立即到达,但希腊字符不可读.有任何想法吗?
编辑
提出的另一个问题:第二个论点to接受一个收件人.如果想将其发送给多个人怎么办?(我想会尝试将功能提供给收件人矢量) - 好的,这很有用sendmail.但是,我并不完全满意,因为每个收件人都无法知道还有谁收到了邮件.
如果没有 ,邮件客户端将无法理解任何编码Content-Type: charset=...,因此您必须添加它:
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")
);
Run Code Online (Sandbox Code Playgroud)
对于 UTF8(我认为应该使用),对于 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")
);
Run Code Online (Sandbox Code Playgroud)
通过隐藏副本进行多重发送也可以使用 header magick 来完成,但我仍然认为 sapply 循环是一个更好的主意 - 然后用户将看到邮件是直接发送给她/他自己的。