PHPackages                             eoghanobrien/php-simple-mail - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. eoghanobrien/php-simple-mail

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

eoghanobrien/php-simple-mail
============================

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

1.7.1(8y ago)20535.0k↓50%87[7 issues](https://github.com/eoghanobrien/php-simple-mail/issues)MITPHPPHP &gt;=5.2.0CI failing

Since Jan 24Pushed 3y ago18 watchersCompare

[ Source](https://github.com/eoghanobrien/php-simple-mail)[ Packagist](https://packagist.org/packages/eoghanobrien/php-simple-mail)[ Docs](https://github.com/eoghanobrien/php-simple-mail)[ RSS](/packages/eoghanobrien-php-simple-mail/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (11)Used By (0)

README
======

[](#readme)

[![Build Status](https://camo.githubusercontent.com/8d4abc2a58ad0f543d7e5ea75dd2efac1356b1d9e780515615fa87c01b31646a/68747470733a2f2f7472617669732d63692e6f72672f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/eoghanobrien/php-simple-mail)[![Latest Stable Version](https://camo.githubusercontent.com/a44013ee71ceeb65c4a583b80ee45f5a0e911f1ce3a18b232a86dc58fb50347c/68747470733a2f2f706f7365722e707567782e6f72672f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2f762f737461626c652e706e67)](https://packagist.org/packages/eoghanobrien/php-simple-mail)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/9ab1fa3b42097c2db86609ecba5c9ffb0b8df6e8e7ac4ca3bbfa95b2b77a9795/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2f6261646765732f7175616c6974792d73636f72652e706e673f733d61363835306334656635316330643536656435303531336433373439643663313631376466616666)](https://scrutinizer-ci.com/g/eoghanobrien/php-simple-mail/)[![Code Coverage](https://camo.githubusercontent.com/acfc94e04299b71746491f50c1e6c7ab4d1287316a7e12a6e2beffd6f80da3ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2f6261646765732f636f7665726167652e706e673f733d64313637653766616632333437316465656566363964323666663233383132613634653734333236)](https://scrutinizer-ci.com/g/eoghanobrien/php-simple-mail/)[![Total Downloads](https://camo.githubusercontent.com/a46d04792822b43ddb9ff23556cd6f015853513a88e8a0fda32de2d5414dc1bc/68747470733a2f2f706f7365722e707567782e6f72672f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/eoghanobrien/php-simple-mail)[![License](https://camo.githubusercontent.com/4430bf1914eefc6a1729a093a3177b121596ceba5ecacb50572b7e0d676d7fce/68747470733a2f2f706f7365722e707567782e6f72672f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2f6c6963656e73652e706e67)](https://packagist.org/packages/eoghanobrien/php-simple-mail)[![PHP 7 ready](https://camo.githubusercontent.com/f6b02e4edf3922a9f11a635c2e9c66b9ee7bfef9b6286c6d82ef2989d4d83056/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f656f6768616e6f627269656e2f7068702d73696d706c652d6d61696c2f6d61737465722f62616467652e737667)](https://travis-ci.org/eoghanobrien/php-simple-mail)

Introduction
------------

[](#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
-------------------------

[](#installation-via-composer)

```
$ composer require eoghanobrien/php-simple-mail

```

Usage
-----

[](#usage)

### Instantiating the class.

[](#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

[](#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

[](#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('john.smith@example.com', 'John Smith');
```

### `Cc` header

[](#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', 'john.smith@example.com');
```

### `Bcc` header

[](#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', 'john.smith@example.com');
```

### `Subject` header

[](#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

[](#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

[](#html-emails)

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

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

### `send` emails

[](#send-emails)

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

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

### Full example of sending an email

[](#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' => 'bill@example.com'])
    ->setBcc(['Steve Jobs' => 'steve@example.com'])
    ->setHtml()
    ->setWrap(100)
    ->send();

echo ($send) ? 'Email sent successfully' : 'Could not send email';
```

### Example of sending an email with attachments

[](#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' => 'bill@example.com'])
    ->setBcc(['Steve Jobs' => 'steve@example.com'])
    ->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
-------

[](#license)

php-simple-mail is free and unencumbered public domain software. For more information, see  or the accompanying MIT file.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~168 days

Recently: every ~328 days

Total

10

Last Release

2985d ago

Major Versions

0.9.0 → 1.0.02014-01-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/64713d35b14b6b3f309bbf4c0f5ea3b82a711ffcf2947af877df25999c5881df?d=identicon)[eoghanobrien](/maintainers/eoghanobrien)

---

Top Contributors

[![eoghanobrien](https://avatars.githubusercontent.com/u/22921?v=4)](https://github.com/eoghanobrien "eoghanobrien (5 commits)")[![md2perpe](https://avatars.githubusercontent.com/u/543239?v=4)](https://github.com/md2perpe "md2perpe (5 commits)")[![iammerrick](https://avatars.githubusercontent.com/u/109635?v=4)](https://github.com/iammerrick "iammerrick (3 commits)")[![shoxty](https://avatars.githubusercontent.com/u/179248?v=4)](https://github.com/shoxty "shoxty (2 commits)")[![ndt](https://avatars.githubusercontent.com/u/290720?v=4)](https://github.com/ndt "ndt (2 commits)")[![dweingart](https://avatars.githubusercontent.com/u/3514416?v=4)](https://github.com/dweingart "dweingart (2 commits)")[![gabalis](https://avatars.githubusercontent.com/u/424454?v=4)](https://github.com/gabalis "gabalis (1 commits)")[![fzmaster](https://avatars.githubusercontent.com/u/235282?v=4)](https://github.com/fzmaster "fzmaster (1 commits)")

---

Tags

attachmentschainable-methodsemailsphpemailphp5

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/eoghanobrien-php-simple-mail/health.svg)

```
[![Health](https://phpackages.com/badges/eoghanobrien-php-simple-mail/health.svg)](https://phpackages.com/packages/eoghanobrien-php-simple-mail)
```

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.6k691.3M307](/packages/egulias-email-validator)[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.5k47.5M164](/packages/sendgrid-sendgrid)[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94944.1M110](/packages/pelago-emogrifier)[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48519.5M75](/packages/soundasleep-html2text)[opcodesio/mail-parser

Parse emails without the mailparse extension

226.8M8](/packages/opcodesio-mail-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
