是否可以在 R 中使用 sendmail 抄送收件人?

2024-01-08

我想从 R 向多个收件人发送一封邮件。我可以使用sendmail功能,但当收件人收到电子邮件时,他们只能看到自己的电子邮件地址to场地。看起来 sendmail 内部循环并向每个收件人发送单独的电子邮件,这不是真的carbon copy。重要的是,每个收件人都可以看到其特定电子邮件的所有收件人(业务要求,因为他们需要回复此电子邮件的所有收件人)。我如何使用 R 来实现这一目标?

my code

require(sendmailR)
to <- c("[email protected] /cdn-cgi/l/email-protection")
header <- list(cc=c("[email protected] /cdn-cgi/l/email-protection"))
x <- sendmail("[email protected] /cdn-cgi/l/email-protection", to, "test", "testing", header=header,control=list(smtpServer=server,verbose=TRUE))
<< 220 equity.xyz.com ESMTP Sendmail 8.11.7p1+Sun/8.11.7; Thu, 11 Jul 2013 21:31:43 -0400 (EDT)
>> HELO  HKD03836654
<< 250 equity.xyz.com Hello HKD03836654.gbl.ad.net [169.34.175.142], pleased to meet you
>> MAIL FROM:  [email protected] /cdn-cgi/l/email-protection
<< 250 2.1.0 [email protected] /cdn-cgi/l/email-protection... Sender ok
>> RCPT TO:  [email protected] /cdn-cgi/l/email-protection
<< 250 2.1.5 [email protected] /cdn-cgi/l/email-protection... Recipient ok
>> DATA
<< 354 Enter mail, end with "." on a line by itself
>> <message data>
<< 250 2.0.0 r6C1Vh101169 Message accepted for delivery
>> QUIT
<< 221 2.0.0 equity.csfb.com closing connection

调试选项的输出。调试输出中不存在标头信息。

> sendmail("[email protected] /cdn-cgi/l/email-protection", to, "test", "testing", header=header,control=list(smtpServer=server,transport="debug"))
From: [email protected] /cdn-cgi/l/email-protection
To: [email protected] /cdn-cgi/l/email-protection
Subject: test
Date: Mon, 15 Jul 2013 02:15:29 -0000
MIME-Version: 1.0
Content-Type: multipart/mixed;             boundary="1a556aa6576e231876dabb67e5a4f58730d3a228654e14705503b6985a6a6707"

This is a message with multiple parts in MIME format.
--1a556aa6576e231876dabb67e5a4f58730d3a228654e14705503b6985a6a6707
Content-Type: text/plain; format=flowed

testing
--1a556aa6576e231876dabb67e5a4f58730d3a228654e14705503b6985a6a6707--

谢谢。


该问题是由于参数的使用引起的header代替headers。然而,这并不像人们想象的那么愚蠢。众所周知,我们在调用函数时可以缩写参数名称:

myfun <- function(xx = 1) print(xx)
myfun(x = 2)
# [1] 2

当有...:

myfun <- function(xx = 1, ...) print(xx)
myfun(x = 2)
[1] 2

但在这种情况下,我们有一个不同且不常见的参数顺序:

sendmail(from, to, subject, msg, ..., headers = list(), control = list())

毫不奇怪,这会导致这样的问题:

myfun <- function(..., yy = 1) print(yy)
myfun(y = 2)
[1] 1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以在 R 中使用 sendmail 抄送收件人? 的相关文章

随机推荐