Last active
August 29, 2015 14:13
-
-
Save pmichaeljones/949e7ac9af7ff62ff265 to your computer and use it in GitHub Desktop.
Sending Mandrill Merge Variables from a Rails Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContactMailer < ActionMailer::Base | |
def contact_form_email(obj) | |
mail :subject => "Contact Form Submission", | |
:to => "pmichaeljones@gmail.com", | |
:from => "#{obj[:user][:address]}" | |
#THIS IS THE IMPORTANT CHANGE | |
merge_vars = | |
{ | |
"name" => "Patty Jones", | |
"message" => "What up sir?" | |
} | |
#DON'T FORGET TO FORMAT IT AS A JSON OBJECT BEFORE SENDING | |
headers['X-MC-MergeVars'] = merge_vars.to_json | |
headers['X-MC-Template'] = "Contact Email Confirmation" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment