Skip to content

mahen23/php-simple-mail

 
 

Repository files navigation

#README

Build Status Latest Stable Version Scrutinizer Quality Score Code Coverage Total Downloads License

Installation via Composer

{
   "require": {
    "eoghanobrien/php-simple-mail": "dev-master"
  }
}

####Version 1.5

Simple Mail Class provides a simple, chainable PHP class for sending basic emails

$mail = new SimpleMail();
$mail->setTo('[email protected]', 'Your Email')
     ->setSubject('Test Message')
     ->setFrom('[email protected]', 'Domain.com')
     ->addMailHeader('Reply-To', '[email protected]', 'Domain.com')
     ->addMailHeader('Cc', '[email protected]', 'Bill Gates')
     ->addMailHeader('Bcc', '[email protected]', 'Steve Jobs')
     ->addGenericHeader('X-Mailer', 'PHP/' . phpversion())
     ->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')
     ->setMessage('<strong>This is a test message.</strong>')
     ->setWrap(100);
$send = $mail->send();
echo ($send) ? 'Email sent successfully' : 'Could not send email';

####Sending an Attachment

If you are sending an attachment there is no need to add any addGenericHeader()'s. To properly send the attachments the necessary headers will be set for you. You can also chain as many attachments as you want (see example).

$mail = new SimpleMail();
$mail->setTo('[email protected]', 'Your Email')
     ->setSubject('Test Message')
     ->setFrom('[email protected]', 'Domain.com')
     ->addMailHeader('Reply-To', '[email protected]', 'Domain.com')
     ->addMailHeader('Cc', '[email protected]', 'Bill Gates')
     ->addMailHeader('Bcc', '[email protected]', 'Steve Jobs')
     ->addAttachment('example/pbXBsZSwgY2hh.jpg', 'lolcat_finally_arrived.jpg')
     ->addAttachment('example/lolcat_what.jpg')
     ->setMessage('<strong>This is a test message.</strong>')
     ->setWrap(100);
$send = $mail->send();
echo ($send) ? 'Email sent successfully' : 'Could not send email';

License

php-simple-mail is free and unencumbered public domain software. For more information, see http://opensource.org/licenses/MIT or the accompanying MIT file.

About

Simple PHP 5 Email Class with Chainable Methods

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%