All Projects → eoghanobrien → Php Simple Mail

eoghanobrien / Php Simple Mail

Licence: mit
Provides a simple, chainable wrapper for creating and sending emails using the PHP mail() function.

Labels

Projects that are alternatives of or similar to Php Simple Mail

Gif Countdown Timer
Countdown Timer for Emails
Stars: ✭ 9 (-95.59%)
Mutual labels:  emails
Preview Email
Automatically opens your browser to preview Node.js email messages sent with Nodemailer. Made for Lad!
Stars: ✭ 112 (-45.1%)
Mutual labels:  emails
Imapsync
Imapsync is an IMAP transfers tool. The purpose of imapsync is to migrate IMAP accounts or to backup IMAP accounts. IMAP is one of the three current standard protocols to access mailboxes, the two others are POP3 and HTTP with webmails, webmails are often tied to an IMAP server. Upstream website is
Stars: ✭ 2,201 (+978.92%)
Mutual labels:  emails
Postmarker
Python client library for Postmark API
Stars: ✭ 79 (-61.27%)
Mutual labels:  emails
Swiftmailer
Comprehensive mailing tools for PHP
Stars: ✭ 9,503 (+4558.33%)
Mutual labels:  emails
Eventum
Eventum Issue Tracking System
Stars: ✭ 120 (-41.18%)
Mutual labels:  emails
Holehe
holehe allows you to check if the mail is used on different sites like twitter, instagram and will retrieve information on sites with the forgotten password function.
Stars: ✭ 568 (+178.43%)
Mutual labels:  emails
Email Dashboard
📪 An interactive emailing management service with scheduling, templating, tracking and A/B testing.
Stars: ✭ 194 (-4.9%)
Mutual labels:  emails
Awesome Emails
✉️ An awesome list of resources to build better emails.
Stars: ✭ 1,379 (+575.98%)
Mutual labels:  emails
Gitmails
An information gathering tool to collect git commit emails in version control host services
Stars: ✭ 142 (-30.39%)
Mutual labels:  emails
Email Extractor
The main functionality is to extract all the emails from one or several URLs - La funcionalidad principal es extraer todos los correos electrónicos de una o varias Url
Stars: ✭ 81 (-60.29%)
Mutual labels:  emails
Gpg Mailer
GnuPG-encrypted emails made easy
Stars: ✭ 93 (-54.41%)
Mutual labels:  emails
Offlineimap
Read/sync your IMAP mailboxes (python2)
Stars: ✭ 1,647 (+707.35%)
Mutual labels:  emails
Jabbar
Find out who is interested in your GitHub Code
Stars: ✭ 14 (-93.14%)
Mutual labels:  emails
Html Email Templates
Free HTML Email Templates created using the Postcards - https://designmodo.com/postcards/
Stars: ✭ 178 (-12.75%)
Mutual labels:  emails
Simplyemail
Email recon made fast and easy, with a framework to build on
Stars: ✭ 779 (+281.86%)
Mutual labels:  emails
React Emails
Create and render emails on the server with React
Stars: ✭ 115 (-43.63%)
Mutual labels:  emails
Hermes
Golang package that generates clean, responsive HTML e-mails for sending transactional mail
Stars: ✭ 2,379 (+1066.18%)
Mutual labels:  emails
Awesome Newsletters
A list of amazing Newsletters
Stars: ✭ 2,468 (+1109.8%)
Mutual labels:  emails
Gulp Mjml
Add Gulp to your MJML workflow!
Stars: ✭ 137 (-32.84%)
Mutual labels:  emails

README

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

Introduction

Simple Mail Class provides a simple, chainable wrapper for creating and sending emails using the PHP mail() function. There are better options out there for sending SMTP email, which are more secure and more reliable than the mail() function. However, sometimes you just need to send a simple email. That's what we cover.

Installation via Composer

$ composer require eoghanobrien/php-simple-mail

Usage

Instantiating the class.

You have two options, you can 'new up' the class in the traditional way:

$mailer = new SimpleMail();

or instantiate it using the named static constructor make()

$mailer = SimpleMail::make();

The static constructor can be useful when you want to continue chaining methods after instantiating.

SimpleMail::make()
->setTo($email, $name)
->setFrom($fromEmail, $fromName)
->setSubject($subject)
->setMessage($message)
->send();

To header

The To header can be called multiple time, in order to pass more than one To address, simply call the setTo method as many times as needed. It takes two string parameters. The first parameter is for the email address, the second is for the name.

SimpleMail::make()
 ->setTo($email1, $name1)
 ->setTo($email2, $name2);

From header

You can carbon copy one or more addresses using the setBcc method. It takes two string parameters. The first parameter is for the email address, the second is for the name.

SimpleMail::make()
  ->setFrom('[email protected]', 'John Smith');

Cc header

You can carbon copy one or more addresses using the setCc method. It takes an array of $name => $email pairs. Alternatively, you can pass a simple numerically keyed array an the value is assumed to be the email.

SimpleMail::make()
  ->setCc(['John Smith', '[email protected]');

Bcc header

You can blind carbon copy one or more addresses using the setBcc method. It takes an array of $name => $email pairs. Alternatively, you can pass a simple numerically keyed array an the value is assumed to be the email.

SimpleMail::make()
  ->setBcc(['John Smith', '[email protected]');

Subject header

You can set the subject using setSubject method. It takes a string as the only parameter.

SimpleMail::make()
    ->setSubject("Important information about your account");

Message header

You can set the message using setMessage method. It takes a string as the only parameter.

SimpleMail::make()
    ->setMessage("My important message!");

HTML emails

If you want to include HTML in your email. Simply call the setHtml() method. It takes no parameters.

SimpleMail::make()
    ->setMessage("<strong>My important message!</strong>")
    ->setHtml();

send emails

Once you've set all your headers. Use the send() method to finally send it on it's way.

SimpleMail::make()
    ->setMessage("<strong>My important message!</strong>")
    ->send();

Full example of sending an email

$send = SimpleMail::make()
    ->setTo($email, $name)
    ->setFrom($fromEmail, $fromName)
    ->setSubject($subject)
    ->setMessage($message)
    ->setReplyTo($replyEmail, $replyName)
    ->setCc(['Bill Gates' => '[email protected]'])
    ->setBcc(['Steve Jobs' => '[email protected]'])
    ->setHtml()
    ->setWrap(100)
    ->send();
    
echo ($send) ? 'Email sent successfully' : 'Could not send email';

Example of sending an email with attachments

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).

$send = SimpleMail::make()
    ->setTo($email, $name)
    ->setFrom($fromEmail, $fromName)
    ->setSubject($subject)
    ->setMessage($message)
    ->setReplyTo($replyEmail, $replyName)
    ->setCc(['Bill Gates' => '[email protected]'])
    ->setBcc(['Steve Jobs' => '[email protected]'])
    ->setHtml()
    ->setWrap(100)
    ->addAttachment('example/pbXBsZSwgY2hh.jpg', 'lolcat_finally_arrived.jpg')
    ->addAttachment('example/lolcat_what.jpg')
    ->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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].