Laravel SDK interface for Pepipost
This package maps the Pepipost SDK to the laravel application
To use this package required your Pepipost Api Key. Please make it Here.
We are trying to make our libraries Community Driven- which means we need your help in building the right things in proper order we would request you to help us by sharing comments, creating new issues or pull requests.
We welcome any sort of contribution to this library.
The latest 1.0.0 version of this library provides is fully compatible with the latest Pepipost v5.1 API.
For any update of this library check Releases.
A free account on Pepipost. If you don't have a one, click here to signup.
$ composer create-project laravel/laravel example-app
$ composer require pepipost/pepipost-lib
-
Add API key to the .env file
PEPIPOST_API_KEY='<API_TOKEN_KEY>'
-
Export the config file to the laravel app
$ php artisan vendor:publish --provider="Pepipost\PepipostLib\PepipostServiceProvider" --tag="config"
-
Create Controller
php artisan make:controller sendMail
-
Update controller with email structure
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Pepipost\PepipostLib\Models; use Pepipost\PepipostLib\PepipostLib as Mailer; class Mailsend extends Controller { public static function send(Request $request){ $body = new Models\Send; $body->from = new Models\From; $body->from->email = '[email protected]'; $body->from->name = 'John'; $body->subject = 'Pepipost Test Mail from laravel'; $body->content = array(); $body->content[0] = new Models\Content; $body->content[0]->type = Models\TypeEnum::HTML; $body->content[0]->value = '<html><body>Hello, Welcome to Pepipost Family àèìòù.<br>My name is [% name %].<br>my love is sending [% love %]</body> <br></html>'; $body->attachments[0] = new Models\Attachments; $body->attachments[0]->attach(storage_path('Discussions.pdf')); #optional $body->attachments[0]->name = 'discussionwithteam.pdf'; $body->personalizations = array(); $body->personalizations[0] = new Models\Personalizations; $body->personalizations[0]->attributes = ["name" => "Pepi", "love" => "email"]; $body->personalizations[0]->tokenTo = '<identity-string>'; $body->personalizations[0]->to = array(); $body->personalizations[0]->to[0] = new Models\EmailStruct; $body->personalizations[0]->to[0]->name = 'Doe'; $body->personalizations[0]->to[0]->email = '[email protected]'; $body->personalizations[0]->cc = array(); $body->personalizations[0]->cc[0] = new Models\EmailStruct; $body->personalizations[0]->cc[0]->name = 'elina'; $body->personalizations[0]->cc[0]->email = '[email protected]'; $mailer = new Mailer(); try { var_dump($mailer->sendMail($body)); } catch (Pepipost\PepipostLib\APIException $e) { return $e->getMessage; } } }
-
Create Route in routes/web.php
Route::get('/sendmail', function () { return App::call('App\Http\Controllers\Mailsend@send'); });
Host your laravel project and enter url- http://your_url.com/sendmail in browser
This will send email and display Email sent successfully on browser.
For more advanced usage you can check the advance usage doc for getting help with more complicated scenarios.
v1.0.0 has been released! Please see the release notes for details.
All updates to this library are documented in our 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-laravel library is guided and supported by the Pepipost Developer Experience Team . This pepipost library is maintained and funded by Pepipost Ltd. The names and logos for pepipost gem are trademarks of Pepipost Ltd.