Skip to content

Instantly share code, notes, and snippets.

@JamesChevalier
Created November 3, 2014 16:36
Show Gist options
  • Save JamesChevalier/6868539286a5c291522b to your computer and use it in GitHub Desktop.
Save JamesChevalier/6868539286a5c291522b to your computer and use it in GitHub Desktop.
MailChimp signup in Ruby using mailchimp-api gem without double opt-in
require 'mailchimp'
mailchimp = Mailchimp::API.new(ENV['mailchimp_api_key'])
mailchimp.lists.subscribe(ENV['mailchimp_list_id'],
{ email: 'test@example.com' },
{ 'FNAME' => 'First Name', 'LNAME' => 'Last Name' },
'html',
false)
# So the format is:
# mailchimp.lists.subscribe(list_id, { email: address }, { merge_vars }, 'email type', double_optin_boolean)
@gregblass
Copy link

Why they would default double opt-in to true is beyond me. If you're adding people through an API, how would that ever be the intended behavior? Oh well. Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment