abiodun/mailswifter

Mail swifter is a free mailer built on swiftmailer for html template injection and data parser

1.0.1 2018-12-11 13:26 UTC

This package is not auto-updated.

Last update: 2021-11-25 02:37:11 UTC


README

Mail swifter is a free mailer built on swiftmailer for html template injection and data parser.

Installation

composer require abiodun/mailswifter

Usage

use Abiodun\MailSwifter\MailProvider

index.php

    $mail_provider = new MailProvider([
        'username' => 'username@gmail.com',
        'password' => 'password',
        'smtp' => 'smtp.gmail.com',
    ]);

    $mail_provider->from = ['username@gmail.com' => 'Testing MailSwifter'];
    $mail_provider->to = ['username@gmail.com', 'username@gmail.com' => 'Mailing'];

    $mail_provider->subject = 'New Mail Test';

    $file = __DIR__ . '/sample.html';
    $data_list = [
        'name' => ' ',
        'url' => 'http://info.google.com',
        'category' => 'Fashion',
    ];
    $resp = $mail_provider->template($file, $data_list);
    $resp = $mail_provider->send();

sample.html

    <h1>This is a sample for the mail </h1>
    <p> i surely believe this would work so well</p>

    <p>Name is: [name] </p>
    <p>Url: [url]</p>
    <p>Category: [category]</p>
    <p>i'm so happy here </p>