Ask A Question


You’re not receiving notifications from this thread.

How do i collect the users emails into mandrill ?

Ahmed Althani asked in Gems / Libraries

I have watched the mandrill tutorial. I just have a quick question. How can i link the list on mandrill or any email service with the users emails (when the user signs up ) and update the list whenever someone signs up ? Thanks


Hey Ahmed,

Sorry for the slow reply on this one. You can add an after_create callback to your User model to add the email to the mailing list via their API. If you're using Mailchimp, you can use the Gibbon gem to do that.

I do something like this for GoRails when someone subscribes:

class User
    def add_to_mailchimp
      id: "a04070a071",
      email: {email: email},
      double_optin: false,
      merge_vars: {
        FNAME: first_name,
        LNAME: last_name,
        PLAN: (subscribed? ? "screencast-9" : ""),
    ) if Rails.env.production?
  rescue Gibbon::MailChimpError => e
    Rails.logger.error "Unable to add #{email} to mailchimp: #{e}"
# config/initializers/gibbon.rb
$gibbon = Rails.application.secrets.mailchimp_api_key
# config/secrets.yml
  mailchimp_api_key: MY_API_KEY

Thanks for your help Chris :) !!!

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,387+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.