ruby-on-railsapirubygemsmailchimpgibbon

rails - Gibbon mailchimp gem adds subscriber to list but does not send confirmation email


I am using devise and the gibbon gem to have users sign up for my site. The gibbon gem works in that the user is added to the list on mailchimp, but they are not sent a confirmation email, which, according to the documentation, I believe my code should do. Here is the relevant code:

class User < ActiveRecord::Base
    before_create :do_mailchimp

    def do_mailchimp
        gb = Gibbon::API.new("my_api_key")
        gb.lists.subscribe({:id => 'my_mailchimp_id', 
         :email => {:email => self.email }, :merge_vars => {:WHAT_ARE_Y => self.type},
         :double_optin => false})
    end

How do I get it to send the confirmation email?


Solution

  • If you want to send them a confirmation email so they can confirm their membership in the list, then you need to remove the following code from your api call:

    :double_optin => false
    

    Mailchimp's API documentation states that the double optin option defaults to true. Gibbon's gem does not change this behavior.

    Of course you can just change the value to true to be more explicit, but for future readers, it's important to know that the default setting is true so you are not caught off guard.