Ruby Net :: SMTP-使用密件抄送发送电子邮件:收件人 [英] Ruby Net::SMTP - Send email with bcc: recipients
问题描述
我想使用Ruby Net :: SMTP发送电子邮件。例程
I would like to use Ruby Net::SMTP to send email. The routine
send_message( msgstr, from_addr, *to_addrs )
在我的用于发送电子邮件的代码中效果很好,但是从 API 如何将电子邮件发送到需要盲目复制的人员列表(bcc :)。
works well in my code for sending email, but it is not clear from this API how to send email to a list of people that need to be blind copied (bcc:).
我错过了什么吗,还是用Net :: SMTP无法实现?
Am I missing something, or is it just not possible with Net::SMTP?
推荐答案
send_message
的 to_addrs
参数指定地址的信封。在 to_addrs
中包含地址对邮件头中包含的to和cc地址没有影响。
The to_addrs
parameter of send_message
specifies the envelope to addresses. Including an address in to_addrs
has no effect on the to and cc addresses that get included in the message header.
要密件抄送收件人,请将地址包含在 to_addrs
参数中,但不要将其包含在 msgstr
的标题中。例如:
To bcc a recipient, include the address in the to_addrs
parameter, but don't include it in the headers in msgstr
. For example:
msgstr = <<EOF
From: from@example.org
To: to@example.org
Cc: cc@example.org
Subject: Test BCC
This is a test message.
EOF
Net::SMTP.start(smtp_server, 25) do |smtp|
smtp.send_message msgstr, 'from@example.org',
'to@example.org', 'cc@example.org', 'bcc@example.org'
end
这将向三个收件人发送电子邮件:to@example.org,cc@example.org和bcc @ example.org。在收到的邮件中仅可见to@example.org和cc@example.org。
This will send an email to three recipients: to@example.org, cc@example.org and bcc@example.org. Only to@example.org and cc@example.org will be visible in the received message.
这篇关于Ruby Net :: SMTP-使用密件抄送发送电子邮件:收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!