如何向两个收件人发送电子邮件,让两个收件人在“收件人”字段中都能看到彼此的信息?

3

我如何发送一封邮件给两个人,让他们都在收件人字段中看到对方?

以下是我的代码,它可以向两个人发送电子邮件,但是两个电子邮件收件人都看不到对方。 我正在使用Mandrill发送我的电子邮件(不知道这些信息是否有帮助)。

User_mailer.rb(app / mailers中的文件)

class UserMailer < ApplicationMailer
default from: 'Mauricio@example.com'

def email(user)
   mail(to: "1@gmail.com, 2@gmail.com",
   subject: 'Send email to 2 email accounts', 
   body: 'Email to be sent to 2 email accounts. Both recipients should see each other.')
end

Routes.rb (File in Config)

get 'sendemail' => 'users#send_email'

new.html.erb (File in app/views/users)

<%= link_to "Send email to both emails", sendemail_path %>

users_controller.rb(位于app/controllers文件夹)

def send_email
   UserMailer.email(@user).deliver
   redirect_to users_path
end
2个回答

5

请确保您发送了X-MC-PreserveRecipients头,并将其设置为true

If you send to more than one recipient at a time and want all recipients to
see each other recipient's information, use the X-MC-PreserveRecipients 
header. Recipients will be able to reply-all and see other recipient
information if this is set to true. If it's set to false, Mandrill will 
rewrite the To and Cc headers for your email and only show information 
about an individual recipient.

https://mandrill.zendesk.com/hc/en-us/articles/205582117-Using-SMTP-Headers-to-customize-your-messages#preserve-recipient-headers-for-group-emails


谢谢!我将X-MC-PreserveRecipients设置为true,然后它就起作用了。 - Mauricio

3
Mandrill的消息API可以实现此功能---将preserve_recipients设置为true

谢谢!Mandrill API非常有帮助,我了解到可以将许多功能整合到我的电子邮件中。我将保留收件人设置为true,它也起作用了。 - Mauricio

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接