laasti / mailer
A very lightweight PHP email sender
v2.1.1
2016-11-15 15:34 UTC
Requires
- php: >=5.3.2
- psr/log: ~1.0
Requires (Dev)
- league/container: ~2.0
- monolog/monolog: ~1.13
This package is auto-updated.
Last update: 2024-10-20 23:13:25 UTC
README
=======
A lightweight mail sender, credits to https://github.com/txthinking/Mailer for the inspiration and SMTP server.
Installation
$ composer require laasti/mailer
Usage
<?php use Laasti\Mailer; $server = new Servers\SMTP($logger, $host, $username, $password, $port); $ok = (new Mailer($server)) ->setFrom('You', '') //your name, your email ->setFakeFrom('heelo', 'bot@fake.com') // if u want, a fake name, a fake email ->addTo('Cloud', 'cloud@txthinking.com') ->setSubject('Test Mailer') ->setBody('Hi, I <strong>love</strong> you.') ->addAttachment('host', '/etc/hosts') ->send(); var_dump($ok);
OR
<?php use Laasti\Mailer\Servers\SMTP; use \Laasti\Mailer\Message; use \Monolog\Logger; $server = new SMTP($logger, $host, $username, $password, $port); $mailer = new Mailer($server); $message = new Message(); $message->setFrom('Tom', 'your@mail.com') // your name, your email ->setFakeFrom('heelo', 'bot@fake.com') // if u want, a fake name, a fake email ->addTo('Cloud', 'cloud@txthinking.com') ->setSubject('Test Mailer') ->setBody('<h1>For test</h1>') ->addAttachment('host', '/etc/hosts'); $ok = $mailer->send($message); var_dump($ok);
A number of servers are available: FileServer (prints message to file), Mail, NullServer (does nothing), SMTP, Sendmail
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
History
See CHANGELOG.md for more information.
Credits
Author: Sonia Marquette (@nebulousGirl)
License
Released under the MIT License. See LICENSE file.