Fluttermail API Overview

This guide helps to simulate API requests using the interface within Fluttermail software. You will get all the required information you will need to make API requests.

In this guide, we are going to make an API, to add a new subscriber to the existing list. You will also find the sample code in PHP.

To make an API request to Fluttermail software, you will need the following information:

API URL
API Key
API Action
API Output
POST Parameters


#1. Login to your Fluttermail account.

#2. Go to the Accounts -> Your settings.

Fluttermail API

API URL and API Key are already exist under the 'Settings' page.

#3. Select the option 'Subscribers' -> 'Add Subscriber' from the 'API Explorer' drop-down menu. To add a subscriber, the action (api_action) is 'subscriber_add'. The default API Output (api_output) is 'json'.

Fluttermail API

#4. Go to the 'Method Parameters' section, select your desired list. Enter values for the fields Email Address, First Name and Last Name.

Uncheck the 'Test mode' option. Click the 'View API Response' button.

Fluttermail API

#5. You will get the required parameters under 'POST Parameters'.

Fluttermail API

#6. Below is an example of API in PHP, using the above information:

<?php
$apiurl = 'https://em.fluttermail.com';
$params = array(
    'api_key'      => 'API_KEY', // Replace with your API Key
    'api_action'   => 'subscriber_add', // Action to add a subscriber  
    'api_output'   => 'serialize', // api_output can be xml or json or serialize  
);
// Define the data
$post = array(
    'email'                    => 'johndoe@example.com',
    'first_name'               => 'John',
    'last_name'                => 'Doe',
    'p[1234]'                  => 1234, // List ID
    'status[1234]'              => 1, // 1: active, 2: unsubscribed
    //(REPLACE '1234' WITH ACTUAL LIST ID)   
);
// Converts the input fields to the proper format
$query = "";
foreach( $params as $key => $value ) $query .= $key . '=' . urlencode($value) . '&';
$query = rtrim($query, '& ');

$data = "";
foreach( $post as $key => $value ) $data .= $key . '=' . urlencode($value) . '&';
$data = rtrim($data, '& ');

// clean up the url
$apiurl = rtrim($apiurl, '/ ');

if ( !function_exists('curl_init') ) die('CURL not supported.');

// Final API request using CURL
$api = $apiurl . '/admin/api.php?' . $query;

$request = curl_init($api);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_POSTFIELDS, $data);
curl_setopt($request, CURLOPT_FOLLOWLOCATION, true);
$response = (string)curl_exec($request);
curl_close($request);

if ( !$response ) {
    die('Nothing was returned. Do you have a connection to Fluttermail server?');
}
$result = unserialize($response);

// The result
print_r($result);
?>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us