2

I am trying to use the gem mailchimp-api-ruby to add users to a list. But when i use mailchimp.lists.subscribe it sends an email to the users asking them to confirm before they end up in the list. I know that double_optin => false should fix this but i haven't been able to make it work. I am sure it is some kind of formatting that is wrong. I don't think the documentation is very clear and have tried every combination i can think of. Could someone please help me :)

Right now i have the following:

mailchimp = Mailchimp::API.new(Rails.application.secrets.mailchimp_api_key)

mailchimp.lists.subscribe("list_id", 
{"email" => "test@gmail.com" }, 
{'FNAME' => @user.firstname, 'LNAME' => @user.lastname}, 
:EMAIL_TYPE => 'html', 
:double_optin => false
)

1 Answers1

1

I had to do something like this:

double_opt_in = false
send_welcome = true
mailchimp.lists.subscribe(id,{"email" => email}, nil, 'html', double_opt_in, false, true, send_welcome)

per: https://www.rubydoc.info/gems/mailchimp-api/2.0.6/Mailchimp/Lists#subscribe-instance_method

originate
  • 21
  • 1