sendmailR:将编码消息提交到本地SMTP服务器 [英] sendmailR: Submit encoded message to local SMTP server

查看:108
本文介绍了sendmailR:将编码消息提交到本地SMTP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的帮助,以便使用函数sendmail {sendmailR}发送包含希腊语中的文本的电子邮件消息。

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

我尝试使用功能 iconv ,像这样,但它没有工作

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?

编辑

出现的另一个问题是:
第二个参数接受一个收件人。如果要发送到多个? (我想'尝试将 sendmail 函数尝试向收件人的向量) - 好的,这是有效的。但是,我并不完全满意,因为每个收件人都无法知道还有谁收到了这个消息。

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.

推荐答案

邮件客户端将无法理解任何编码,而没有 Content-Type:charset = ... ,所以你必须添加它:

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")
);

这是为UTF8(我相信应该使用),CP1253:

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")
);

多次隐藏的副本也可以用头版魔法完成,仍然我觉得sapply循环是一个更好的主意 - 然后用户将看到邮件直接发送给她/他自己。

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.

这篇关于sendmailR:将编码消息提交到本地SMTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆