Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Send E-Mails With BCC in Rails 3

How can I send e-mails with the BCC header? I follow the ruby on rails guide and set :bcc => "[email protected]" and it doesn't work.

Thanks

edit by corroded Here's the code I tried:

def booking_confirmed_email(booking)   @booking = booking   mail(:to => booking.contact_email,        :bcc => "[email protected]",        :subject => "Congratulations, #{booking.contact_name}!") end 

also tried:

def booking_confirmed_email(booking)   @booking = booking   mail(:to => booking.contact_email,        :bcc => ["[email protected]"],        :subject => "Congratulations, #{booking.contact_name}!") end 

to no avail

like image 577
silkwormy Avatar asked Jul 04 '11 21:07

silkwormy


1 Answers

Full details here:

http://api.rubyonrails.org/classes/ActionMailer/Base.html

Short answer:

mail(:to => "[email protected]" ,  :subject => "Example Subject",      :bcc => ["[email protected]", "Order Watcher <[email protected]>"] ,      :cc => "[email protected]" ) 

note how you can pass an array of email addresses to each of the :to, :cc, :bcc options.

RailsCast:

http://railscasts.com/episodes/206-action-mailer-in-rails-3

like image 133
Tilo Avatar answered Oct 19 '22 02:10

Tilo