This is the SendinBlue Php library. It implements the various exposed APIs that you can read more about on https://apidocs.sendinblue.com.
-
You will need to first get the Access key from SendinBlue.
-
Our library supports a timeout value, default is 30,000 MS ( 30 secs ), which you can pass as 3rd parameter in Mailin class Object.
-
You can install the SendinBlue API using Composer. Just add the following to your composer.json:
"require": { "mailin-api/mailin-api-php": "1.0.*" } }``` You will then need to: -
Run
composer installto get these dependencies added to your vendor directory -
Add the autoloader to your application with this line:
require("vendor/autoload.php")
OR
-
Simply install by running below command
composer require mailin-api/mailin-api-php
You can use below sample script to get started.
<?php
use Sendinblue\Mailin
/*
* This will initiate the API with the endpoint and your access key.
*
*/
$mailin = new Mailin('https://api.sendinblue.com/v2.0','Your access key', 5000); // Optional parameter: Timeout in MS
/** Prepare variables for easy use **/
$data = array( "to" => array("[email protected]"=>"to whom!"),
"cc" => array("[email protected]"=>"cc whom!"),
"bcc" =>array("[email protected]"=>"bcc whom!"),
"from" => array("[email protected]","from email!"),
"replyto" => array("[email protected]","reply to!"),
"subject" => "My subject",
"text" => "This is the text",
"html" => "This is the <h1>HTML</h1><br/>
This is inline image 1.<br/>
<img src=\"{myinlineimage1.png}\" alt=\"image1\" border=\"0\"><br/>
Some text<br/>
This is inline image 2.<br/>
<img src=\"{myinlineimage2.jpg}\" alt=\"image2\" border=\"0\"><br/>
Some more text<br/>
Re-used inline image 1.<br/>
<img src=\"{myinlineimage1.png}\" alt=\"image3\" border=\"0\">",
"attachment" => array(),
"headers" => array("Content-Type"=> "text/html; charset=iso-8859-1","X-param1"=> "value1", "X-param2"=> "value2",...,"X-Mailin-custom"=>"my custom value", "X-Mailin-IP"=> "102.102.1.2", "X-Mailin-Tag" => "My tag"),
"inline_image" => array('myinlineimage1.png' => "your_png_files_base64_encoded_chunk_data",'myinlineimage2.jpg' => "your_jpg_files_base64_encoded_chunk_data")
);
var_dump($mailin->send_email($data));
?>- To explore more, you should visit the SendinBlue API documentation.
List of API calls that you can make, you can click to read more about it. Please do note that the order of parameters are important.
- get_account() - Get your account information
- get_smtp_details() - Get your SMTP account information
- create_child_account($data) - Create a Reseller child account
- update_child_account($data) - Update a Reseller child account
- delete_child_account($data) - Delete a Reseller child account
- get_reseller_child($data) - Get Reseller child accounts
- add_remove_child_credits($data) - Add/Remove Reseller child credits
- get_campaigns_v2($data) - Get list of all campaigns or of specific type or status or both
- get_campaign_v2($data) - Get specific campaign object
- create_campaign($data) - Create a campaign
- delete_campaign($data) - Delete a campaign
- update_campaign($data) - Update campaign information
- campaign_report_email($data) - Sending reports to specific emails
- campaign_recipients_export($data) - Export recipients of a campaign
- send_bat_email($data) - Send a test Email (bat)
- create_trigger_campaign($data) - Create a trigger campaign
- update_trigger_campaign($data) - Update trigger campaign information
- share_campaign($data) - Get campaign share link
- update_campaign_status($data) - Modify a campaign status
- get_folders($data) - Get list of all the folder details.
- get_folder($data) - Get all the folder details for folder with id
- create_folder($data) - Create a folder
- delete_folder($data) - Delete folder with folder id
- update_folder($data) - Update folder with folder id
- get_lists($data) - Get all the lists
- get_list($data) - Get information about a list
- create_list($data) - Create a list
- delete_list($data) - Delete a list
- update_list($data) - Updating a list
- display_list_users($data) - Display details of all users for the given lists
- add_users_list($data) - Add users to a list
- delete_users_list($data) - Delete users from a list
- get_attributes() - Listing all attributes
- get_attribute($data) - Listing a certain type attributes
- create_attribute($data) - Creating attributes
- delete_attribute($data) - Deleting attributes of the given type
- get_user($data) - Get information about a user/email
- create_update_user($data) - Create/Update a user information
- delete_user($data) - Deleting user from db is not permitted but this action will unlink him from all lists
- import_users($data) - Import users/emails
- export_users($data) - Export users/emails
- get_processes($data) - Get information about all background processes
- get_process($data) - Get information about a specific process
- get_senders($data) - Get information about all/specific senders
- create_sender($data) - Create a sender
- delete_sender($data) - Delete a sender
- update_sender($data) - Update a sender
- get_report($data) - Retrieve information for all report events
- get_statistics($data) - Get aggregate statistics about emails sent
- get_webhooks($data) - Get list of all registered webhooks or of specific type
- get_webhook($data) - Get information about a webhook
- create_webhook($data) - Registering a webhook
- delete_webhook($data) - Deleting a webhook
- update_webhook($data) - Editing a webhook
- delete_bounces($data) - Deleting bounces
- send_email($data) - Sending out a transactional email
- send_transactional_template($data) - Send templates created on SendinBlue, through SendinBlue smtp.
- create_template($data) - Create a template
- update_template($data) - Update template information
- send_sms($data) - Sending a SMS
- create_sms_campaign($data) - Create a SMS campaign
- update_sms_campaign($data) - Update a SMS campaign
- send_bat_sms($data) - Send a test SMS campaign
####Recommendation:
If you face any error like "Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:func(144):reason(134)\n", with our library then by adding the below line of code just before curl_exec() ( line no. 48 ) in mailin.php file, you may no longer face this issue.
curl_setopt($ch, CURLOPT_CAINFO, "PATH_TO/cacert.pem");The content of the file is available here: http://curl.haxx.se/ca/cacert.pem