Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Rails MailChimp API

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 627
    Comment on it

    We use MailChimp for sending emails, specially when we have to send an email to a bunch of people at once. Using MailChimp we can add new users to our mailing list, we can send a welcome email to the new user and can send a notification to users when something happens to our website.

    Let's create a mailing list in MailChimp. For that first create an account in MailChimp.On your dashboard, you can create a new list.
    From MailChimp account, you will get API key and List id, that you can use in your rails application.

    To get your API key, click your first name on the top right of the dashboard, then go to Account.
    Under the Extras menu, click API Keys. It will generate a new key.
    Now to get the list ID, go to Lists on the left side of your dashboard, and click the List you created. Then go to Settings,and List Name and Defaults. You will get the list Id.

    Now we will use MailChimp API for rails application to subscribe new user to MailChimp
    First, install gem by running the command below.

    gem 'mailchimp-api', require: 'mailchimp'


    bundle install

    and we are done.

    Now add the MAILCHIMP-API-KEY and MAILCHIMP-LIST-ID in your config file or where ever you are keeping the constants.
    First, create an object of MailChimp to access the MailChimp API.

    mailchimp =

    To Subscribe Single User

                       { "email" => ""

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: