This is my first Rails project, and I may be missing something
obvious, but... I need to send emails to a group of people, but the
content is individualised, so I cannot bcc them, so I put it into a
loop. It sends the first email OK then fails with an "uninitialized
constant Admin::PrivateNewslettersController::NewsletterMailer" error.
Fore testing I have reduced it to 3 addresses in test_arry, and taken
out the encryption processing.
In the controller I have:
test_arry = ['email1@mac.com', 'email2@mac.com', 'email3@me.com']
test_arry.each do |an_email|
email = an_email
name = 'john'
encrypted = ['abc']
NewsletterMailer.newsletter_email(email, name, encrypted)
end
In the Mailer I have:
class Admin::NewsletterMailer < ActionMailer::Base
default :from => "administrator@xxxxxxxx"
def newsletter_email(email, name, encrypted)
@name = name
@url = "http://www.xxxxxxx/nl/download/"+encrypted.to_s
mail(:to => email, :subject => "Dark Peak Newsletter")
end
end
on 2011-11-18 09:53
on 2011-11-18 09:55
On Nov 17, 5:26pm, John Dalton <johnrdalt...@gmail.com> wrote: > test_arry.each do |an_email| > email = an_email > name = 'john' > encrypted = ['abc'] > > NewsletterMailer.newsletter_email(email, name, encrypted) That should probably be Admin::NewsletterMailer,if your controller isn't in the Admin module I suspect you're getting lucky the first time round due to a quirk in the rails magic auto require stuff. Fred
on 2011-11-18 15:00
Fred Many thanls, using Admin::NewsletterMailer does seem to have fixed it. John On Nov 18, 8:54am, Frederick Cheung <frederick.che...@gmail.com>
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.