May 6, 2013
def post_notification(recipients, post)
@recipients = recipients
@from = post.author.email_address_with_name
@headers[“bcc”] = SYSTEM_ADMINISTRATOR_EMAIL
@headers[“reply-to”] = “notifications@example.com”
@subject = “[#{post.account.name} #{post.title}]”
@body[“post”] = post
@charset = “iso-8859-1”
end
Rails 4 mailer changes
in rails 4 for each object for sending an email we can change an SMTP settings. means we can do a dynamic smtp settings.by overriding the following method
def my_mailer(receiverobject, smtpobject)
mail to: receiverobject.email, subject: “Welcome!”,
delivery_method_options: { user_name: smtpobject.smtp_user,
password: smtpobject.smtp_password }
end
this will ensure that your settings from environments/production.rb will be override.
we can get an array of email sents through Action Mailer . mostly used in progress bar like functionality like suppose in view we wanted to show a progress bar with the count of how many emails has been sent then we can get this through this ActionMailer::Base.deliveries method
Leave a Reply
You must be logged in to post a comment.