[英]How To Send E-Mails With BCC in Rails 3
如何使用密件抄送 header 發送電子郵件? 我遵循 Rails 指南上的 ruby 並設置:bcc => "email@email.com"
但它不起作用。
謝謝
由 corroded 編輯這是我嘗試過的代碼:
def booking_confirmed_email(booking)
@booking = booking
mail(:to => booking.contact_email,
:bcc => "my@email.com",
:subject => "Congratulations, #{booking.contact_name}!")
end
也試過:
def booking_confirmed_email(booking)
@booking = booking
mail(:to => booking.contact_email,
:bcc => ["my@email.com"],
:subject => "Congratulations, #{booking.contact_name}!")
end
無濟於事
完整的細節在這里:
http://api.rubyonrails.org/classes/ActionMailer/Base.html
簡短的回答:
mail(:to => "some@example.com" , :subject => "Example Subject",
:bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"] ,
:cc => "other@example.com" )
請注意如何將 email 地址數組傳遞給每個:to、:cc、:bcc 選項。
RailsCast:
在您的 user_mailer 上,在您的郵件定義上,添加以下內容:
mail(:subject => "enter your subject", :bcc => "email@email.com")
您還可以讓您的密件抄送接收電子郵件列表
@bcc = User.all.pluck(:email)
然后打電話
mail(:subject => "enter your subject", :bcc => @bcc)
希望這可以幫助。 :)
我只是完全相同的問題。 事實證明,在我的情況下,我正在密件抄送同一個地址。 ActionMailer 或郵件服務器做了一些聰明的事情,並選擇只發送一份 email 的副本。
我改為使用兩個不同的 email 地址,BCC 運行良好。
查看http://railscasts.com/episodes/206-action-mailer-in-rails-3並在相當於 user_mailer.rb 中添加 'default:bcc => "your_required_bcc_email"
如果您正在使用任何隊列適配器(例如 Sidekiq) - 請嘗試重新啟動它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.