A simple mail sender

Installs: 92

Dependents: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

0.6.5 2015-11-09 09:26 UTC


Mail is a small library that aims to provide a light and simple mail implementation.


Pick up the source or install it with Composer :

composer require pyrsmk/mail

Sending a basic e-mail

Mail is built on top of Chernozem to have an ease to use configuration.

$mail=new Mail;
$mail['subject']='Hey, I saw you last night!';
$mail['body']='I saw you. Or not.';

And that's all if you want to send a basic e-mail! Pretty simple, isn't it?

But we have a problem. Our address will be shown as and that is really ugly. Let's correct this :

$mail['from']=array('Lionel McGonagall'=>'');

It will be shown like this : Lionel McGonagall <>.

Sending to more than one recipient works the same way :

    'Peter' => '',
    'Anaïs' => '',
    'Grandma' => ''

That syntax works for cc and bcc parameters too. Note that sender and replyto are accessible too but only with the simple email syntax :


Sending a more complex e-mail

Let's say we want to send a billing e-mail to an user from our site with an eye-candy design in HTML, a text fallback and a PDF file attachment. That's how we can proceed :

$mail['html']='<h1>An awesome title for an awesome bill</h1>';
$mail['body']='Your mail client does not support HTML rendering. So bad.';

That's all we need as configuration ;)

E-mail validation

Additionally, you can validate an e-mail address :

    echo 'The e-mail address is valid';
    echo 'The e-mail address is NOT valid';


MIT in your face.