【发布时间】:2015-11-07 00:21:37
【问题描述】:
如何向 2 个人发送电子邮件,并让他们在电子邮件的收件人字段中看到对方?
下面是我的代码,它确实向两个人发送电子邮件,但两个电子邮件收件人都看不到对方。我正在使用 Mandrill 发送我的电子邮件(不知道这些信息是否有帮助)。
User_mailer.rb(应用程序/邮件程序中的文件)
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(应用程序/视图/用户中的文件)
<%= link_to "Send email to both emails", sendemail_path %>
users_controller.rb(应用程序/控制器中的文件)
def send_email
UserMailer.email(@user).deliver
redirect_to users_path
end
【问题讨论】:
标签: ruby-on-rails ruby email actionmailer mandrill