Official PHP Code library for Pepipost
This SDK contain methods for easily interacting with the Pepipost Email Sending API to send emails within few seconds.
We are trying to make our libraries a Community Driven. To help us building right things in proper order we would request you to help us by sharing comments, creating new issues or pull request.
Inorder to make it Smooth we have Separated installation process with respective OS which will help you to go step by step without any interuption.
-
- 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 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_KEY
which 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.
-
Open Command prompt/Terminal.
-
Change directory to any new directory (Make directory test-- recommended).
-
Download or Clone the Pepipost Repository to the new directory and extract.
-
Check php version using
php -v
-
Check Composer version
composer --version
-
Navigate to your directory where the pepipost-php library is extracted (using cd path\to\directory)
-
Type
composer install
(this will install all the requirement needed to run this library -- Note: After installing, a vendor directory will get auto-created) -
Create a new test file in same directory
test.php
-
Copy the code from simpleUsage.md or sampleExample and paste in 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 wiht 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).
Change your $apiKey = 'api-XX-key-XX-here'
to $apiKey = 'api-key-of-your-pepipost-account';
Similarly, update your Sending Domain from $body->from->fromEmail = '[email protected]';
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:
<?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[0] = new PepipostAPILib\Models\Personalizations;
$body->personalizations[0]->recipient = '[email protected]'; #To/Recipient email address
// Email Header
$body->from = new PepipostAPILib\Models\From;
$body->from->fromEmail = '[email protected]'; #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));
?>
Parameter | Tags | Description |
---|---|---|
apiKey | Mandatory |
This is a unique string for authentication. Example '523326ed4sadasb39dfa932ff5fa84ed9ed8' |
body | Optional |
The body passed will be json format. |
v3 has been released! Please see the release notes for details.
All updates to this library are documented in our CHANGELOG and releases. For any queries, feel free to reach out us at [email protected]
If you are interested in the future direction of this project, please take a look at our open issues and pull requests. We would love to hear your feedback.
pepipost-php library is guided and supported by the Pepipost Developer Experience Team. This pepipost-php library is maintained and funded by Pepipost Ltd. The names and logos for pepipost-php are trademarks of Pepipost Ltd.
This code library was semi-automatically generated by APIMATIC v2.0 and licensed under The MIT License (MIT).