Email Rails 4, Devise & Mandrill

I am trying to create an application in Rails 4.

Over the past 3 years, I have been struggling to find out what / omniauth is (I am still trying to make it work).

Stepping aside from the main problems, while I try to find the will to do so, I tried to set up email using Mandrill.

I found this tutorial that I'm trying to run: https://nvisium.com/blog/2014/10/08/mandrill-devise-and-mailchimp-templates/

I have a mailer called mandrill_devise_mailer.rb

class MandrillDeviseMailer < Devise::Mailer def confirmation_instructions(record, token, opts={}) # code to be added here later end def reset_password_instructions(record, token, opts={}) options = { :subject => "Reset your password", :email => record.email, :global_merge_vars => [ { name: "password_reset_link", # content: "http://www.example.com/users/password/edit?reset_password_token=#{token}" content: "http://www.cr.com/users/password/edit?reset_password_token=#{token}" }, { name: "PASSWORD_RESET_REQUEST_FROM", content: record.full_name } ], :template => "Forgot Password" } mandrill_send options end def unlock_instructions(record, token, opts={}) # code to be added here later end def mandrill_send(opts={}) message = { :subject=> "#{opts[:subject]}", :from_name=> "Reset Instructions", # :from_email=>"example@somecorp.com", :from_email=>["PROD_WELCOME"], :to=> [{"name"=>"#{opts[:full_name]}", "email"=>"#{opts[:email]}", "type"=>"to"}], :global_merge_vars => opts[:global_merge_vars] } sending = MANDRILL.messages.send_template opts[:template], [], message rescue Mandrill::Error => e Rails.logger.debug("#{e.class}: #{e.message}") raise end end 

The differences between the foregoing and what they did in the textbook:

In my mail template mandrill chimp I have:

 <a href="*|password_reset_link|*">Change my password </a> 

When I receive an email with the reset instructions, I get an underlined link to the password change form, which says: "Change my password next to it. I want to" change my password as a shortcut that hides the link text. "

Can anyone see what I did wrong?

+8
email ruby-on-rails devise actionmailer mandrill
source share
1 answer

This is how I created a custom DeviseMailer

 class MyDeviseMailer < Devise::Mailer default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views def reset_password_instructions(record, token, opts={}) opts['from_email'] = "donotreply@mywebsite.com" opts['from_name'] = "Password Reset" #Rails.logger.mail.info "reset_password_instructions #{record.to_json} \n #{token.to_json} \n #{opts.to_json}" super end end 

https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer and Add dynamic value when creating an email subject

-2
source share

All Articles