This SDK contains methods for easily interacting with the Pepipost Email Sending API to send emails in a few seconds.
We are trying to make our libraries community driven and we need your help in building the right things the right way you. Your opinion is very much valued so please share comments, create issues and pull requests.
Table of Contents
Installation (OS Friendly)
For a smooth installation process, we have categorized installation process according to OS:
- A free account on Pepipost. If you don't have a one, click here to signup and get 30,000 emails free every month.
Setup Global Variables
Setup the PEPIPOST API KEY in the library to start sending emails. For example:
- Copy the API KEY from your Pepipost account by navigating to Settings --> Integrations.
- Edit the sample code and replace
PEPIPOST_API_KEYwhich the one you just copied.
- Now the library is ready to authenticate with Pepipost servers for sending emails.
Developers already familar with GIT, Composer and some of the other handy tools can just refer the below steps to quick start with the integration.
If you are not sure of how to integrate this library within your environment, then please refer to our detailed installation guide above.
- Check php version using below command. Required PHP >=5.4.0.
- Verify if the Composer is installed using the below command:
- Clone this repository on your machine using below command:
git clone https://github.com/pepipost/pepipost-sdk-php.git testSDK
- Change directory
- Below will install all the requirement needed to run this library. After installing, a vendor directory will get auto-created
cp simpleUsage.md test.php
- Get your API key and Sending Domain from your Pepipost account.
- apikey will be available under Login to Pepipost -> Settings -> Integration
- Sending Domain will be available under Login to Pepiost -> Settings -> Sending Domains
*Note :: Domains showing with Active status on Sending Domain dashboard are only allowed to send any sort of emails.* In case there are no Sending Domain added under your account, then first add the domain, get the DNS (SPF/DKIM) settings done and get it reviewed by our compliance team for approval. Once the domain is approved, it will be in ACTIVE status and will be ready to send any sort of emails.
- Make the required changes in your script test.php (Adding the apikey and Sending Domain is mandatory).
$apiKey = 'api-XX-key-XX-here' to
$apiKey = 'api-key-of-your-pepipost-account';
Similarly, update your Sending Domain from:
$body->from->fromEmail = 'email@example.com'; to
$body->from->fromEmail = 'admin@your-active-domain-on-pepipost';
- Update the rest of the email related payload like Recipent email address, content of the email etc. Below is the sample code with details of payload:
Sample Code for test.php
<?php require_once "vendor/autoload.php"; $client = new PepipostAPILib\PepipostAPIClient(); $emailController = $client->getEmail(); // Your Pepipost API Key $apiKey = 'api-XX-key-XX-here'; #add apikey from panel here $body = new PepipostAPILib\Models\EmailBody(); // List of Email Recipients $body->personalizations = array(); $body->personalizations = new PepipostAPILib\Models\Personalizations; $body->personalizations->recipient = 'Youremailid@XXX.com'; #To/Recipient email address // Email Header $body->from = new PepipostAPILib\Models\From; $body->from->fromEmail = 'firstname.lastname@example.org'; #Sender Domain. Note: The sender domain should be verified and active under your Pepipost account. $body->from->fromName = 'Test Admin'; #Sender/From name //Email Body Content $body->subject = 'Pepipost mail through php sdk'; #Subject of email $body->content = '<html><body>Hello, Email testing is successful. <br> Hope you enjoyed this integration. <br></html>'; #HTML content which need to be send in the mail body // Email Settings $body->settings = new PepipostAPILib\Models\Settings; $body->settings->clicktrack = 1; #clicktrack for emails enable=1 | disable=0 $body->settings->opentrack = 1; #opentrack for emails enable=1 | disable=0 $body->settings->unsubscribe = 1; #unsubscribe for emails enable=1 | disable=0 $response = $emailController->createSendEmail($apiKey,$body); #function sends email print_r(json_encode($response)); ?>
For more information about the parameters, we would like to recommend our API docs
- Run your script to send your first test email
This will give you following output:
v2.5.0 has been released! Please see the release notes for details.
pepipost-php-sdk library is guided and supported by the Pepipost Developer Experience Team. This pepipost-php-sdk library is maintained and funded by Pepipost Ltd. The names and logos for pepipost-php-sdk are trademarks of Pepipost Ltd.
This code library was semi-automatically generated by APIMATIC v2.0 and licensed under The MIT License (MIT).