2017 © Pedro Peláez
 

library mail

A simple mail sender

image

pyrsmk/mail

A simple mail sender

  • Thursday, May 26, 2016
  • by pyrsmk
  • Repository
  • 2 Watchers
  • 0 Stars
  • 628 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Mail 0.6.8

Mail is a small library that aims to provide a light and simple mail implementation., (*1)

Installing

Pick up the source or install it with Composer :, (*2)

composer require pyrsmk/mail

Sending a basic e-mail

Mail is built on top of Chernozem to have an ease to use configuration., (*3)

$mail = new Mail;
$mail['from'] = 'lionel@example.org';
$mail['to'] = 'peter@another-site.org';
$mail['subject'] = 'Hey, I saw you last night!';
$mail['body'] = 'I saw you. Or not.';
$mail->send();

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

But we have a problem. Our address will be shown as from@example.org and that is really ugly. Let's correct this :, (*5)

$mail['from'] = array('Lionel McGonagall'=>'lionel@example.org');

It will be shown like this : Lionel McGonagall <from@example.org>., (*6)

Sending to more than one recipient works the same way :, (*7)

$mail['to'] = array(
    'Peter' => 'peter@another-site.org',
    'Anaïs' => 'anais@wonderful.net',
    'Grandma' => 'iam@old.com'
);

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

$mail['sender'] = 'peter@another-site.org';
$mail['replyto'] = 'anais@wonderful.net';

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 :, (*9)

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

That's all we need as configuration ;), (*10)

You can also define a filename for an attachment file :, (*11)

$mail['attachments'] = array(
    $_FILES['image1']['name'] => $_FILES['image1']['tmp_name'],
    $_FILES['image2']['name'] => $_FILES['image2']['tmp_name']
);

E-mail validation

Additionally, you can validate an e-mail address :, (*12)

if(Mail::validate('lionel@example.org')){
    echo 'The e-mail address is valid';
}
else{
    echo 'The e-mail address is NOT valid';
}

License

MIT in your face., (*13)

The Versions

26/05 2016

dev-master

9999999-dev

A simple mail sender

  Sources   Download

MIT

The Requires

 

mail smtp sender send sending

26/05 2016

0.6.8

0.6.8.0

A simple mail sender

  Sources   Download

MIT

The Requires

 

mail smtp sender send sending

29/02 2016

0.6.7

0.6.7.0

A simple mail sender

  Sources   Download

MIT

The Requires

 

mail smtp sender send sending

29/02 2016

0.6.6

0.6.6.0

A simple mail sender

  Sources   Download

MIT

The Requires

 

mail smtp sender send sending

09/11 2015

0.6.5

0.6.5.0

A simple mail sender

  Sources   Download

MIT

The Requires

 

mail smtp sender send sending

19/09 2015

0.6.4

0.6.4.0

A simple mail sender

  Sources   Download

MIT

The Requires

 

mail smtp sender send sending

16/09 2015

0.6.3

0.6.3.0

A simple mail sender

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

mail smtp sender send sending

14/03 2015

0.6.2

0.6.2.0

A simple mail sender

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

mail smtp sender send sending

13/03 2014

0.6.1

0.6.1.0

A simple mail object

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

mail