schema31/php-ci-mailer

There is no license information available for the latest version (0.0.4) of this package.

0.0.4 2020-09-08 13:53 UTC

This package is auto-updated.

Last update: 2024-09-08 22:06:26 UTC


README

======

Packagist

Mailer for CodeIgniter.

Install

You can install the library using composer:

$ composer require schema31/php-ci-mailer

How to use

Configurations

Here the list of all configuration attributes supported:

Internal configuration

You can use an array of configurations:

$config = [];
$config['protocol'] = 'smtp';// mail, sendmail, smtp
$config['smtp_host'] = 'smtp_host';// SMTP Server Address.
$config['smtp_user'] = 'smtp_user';// SMTP Username.
$config['smtp_pass'] = 'smtp_pass';// SMTP Password.
$config['smtp_port'] = '25';// SMTP Port.
$config['mailtype'] = 'html';// text or html
$config['smtp_timeout'] = '30';// SMTP Timeout (in seconds).
$config['from_email'] = 'noreply@example.it';
$config['from_name'] = 'CI MAILER';
$config['prefix_subject'] = 'Mailer - ';

$mailer = new \Schema31\CiMailer\Mailer($config);

Configuration file

You can use the file named "cemail.php" in application/config folder and the library loads it automatically:

$mailer = new \Schema31\CiMailer\Mailer();

Adding recipients

You can add a single or multiple recipients (like the "to", "cc", "bcc" recipient) with:

$mailer = new \Schema31\CiMailer\Mailer();

$mailer->setSingleTo("foo01@bar.com"); //Single "to" recipient
$mailer->setSingleCc("foo02@bar.com"); //Single "cc" recipient
$mailer->setSingleBcc("foo03@bar.com"); //Single "bcc" recipient

Or

$mailer = new \Schema31\CiMailer\Mailer();

$mailer->setMultipleTo(["foo01@bar.com", "foo0101@bar.com"]); //Multiple "to" recipient: "foo01@bar.com" and "foo0101@bar.com"
$mailer->setMultipleCc(["foo02@bar.com", "foo0202@bar.com"]); //Multiple "cc" recipient: "foo02@bar.com" and "foo0202@bar.com"
$mailer->setMultipleBcc(["foo03@bar.com", "foo0303@bar.com"]); //Multiple "bcc" recipient: "foo03@bar.com" and "foo0303@bar.com"

Or

$mailer = new \Schema31\CiMailer\Mailer();

$mailer->setSingleTo("foo01@bar.com,foo0101@bar.com"); //Multiple "to" recipient: "foo01@bar.com" and "foo0101@bar.com" comma separated
$mailer->setSingleCc("foo02@bar.com,foo0202@bar.com"); //Multiple "cc" recipient: "foo02@bar.com" and "foo0202@bar.com" comma separated
$mailer->setSingleBcc("foo03@bar.com,foo0303@bar.com"); //Multiple "bcc" recipient: "foo03@bar.com" and "foo0303@bar.com" comma separated

Printing debbuger message

If you want to print debug message after the send of the email:

$mailer = new \Schema31\CiMailer\Mailer();

//...

echo $mailer->printDebugger();

Sending an email

$mailer = new \Schema31\CiMailer\Mailer();

//Method chaining is allowed
$mailer
->setSingleTo("foo01@bar.com")
->setSubject("Email di prova #" . uniqid())
->setMessage("La email di testo")
->send(); //returns true if the email is sent, false otherwise.