Skip to content

pepipost/pepipost-laravel-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pepipostlogo

Packagist Packagist Open Source Helpers Twitter Follow

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.

Table of Content

Installation

Prerequisites

PHP >= 7.x

Composer v2.3.10

Laravel >= 8.x

A free account on Pepipost. If you don't have a one, click here to signup.

Usage

Configuring laravel project

Step 1 - Create New Laravel project

$ composer create-project laravel/laravel example-app

Step 2 - install with composer

$ composer require pepipost/pepipost-lib

Step 3 - Configurations

  1. Add API key to the .env file

    PEPIPOST_API_KEY='<API_TOKEN_KEY>'
    
  2. Export the config file to the laravel app

    $ php artisan vendor:publish --provider="Pepipost\PepipostLib\PepipostServiceProvider" --tag="config"

Step 4- Laravel Steps to create controller and route

  1. Create Controller

    php artisan make:controller sendMail
  2. 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;
                }
            }
        }
  3. Create Route in routes/web.php

    Route::get('/sendmail', function () {
      return App::call('App\Http\Controllers\Mailsend@send');
    });

Step 5 - Testing

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.

Additional Usage

For more advanced usage you can check the advance usage doc for getting help with more complicated scenarios.

Announcements

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]

Roadmap

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.

About

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.

License

MIT

About

Pepipost laravel integration with PHP SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages