作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我如何向两个人发送电子邮件并让他们在电子邮件的收件人字段中看到对方?
下面是我的代码,它确实向两个人发送电子邮件,但两个电子邮件收件人都看不到对方。我正在使用 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(配置文件)
get 'sendemail' => 'users#send_email'
new.html.erb(app/views/users 中的文件)
<%= link_to "Send email to both emails", sendemail_path %>
users_controller.rb(应用/ Controller 中的文件)
def send_email
UserMailer.email(@user).deliver
redirect_to users_path
end
最佳答案
确保您正在发送 X-MC-PreserveRecipients
header 并将其设置为 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.
关于ruby-on-rails - 如何向 2 个收件人发送电子邮件并且两个收件人在收件人字段中看到对方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31998292/
我是一名优秀的程序员,十分优秀!