PHPackages                             lianhua/email - 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. lianhua/email

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

lianhua/email
=============

A simple PHP class for emails

1.0.3(6y ago)0721GPL-3.0PHPPHP &gt;=7.3

Since Mar 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Nevermille/Email)[ Packagist](https://packagist.org/packages/lianhua/email)[ RSS](/packages/lianhua-email/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (6)Used By (1)

Email
=====

[](#email)

[![Build Status](https://camo.githubusercontent.com/cfe72766bfd9a534fb2194f98b523f18b755c5c890331803e67b6fc426e465dc/68747470733a2f2f7472617669732d63692e636f6d2f4e657665726d696c6c652f456d61696c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Nevermille/Email) [![BCH compliance](https://camo.githubusercontent.com/779fca49b678f68a8d2598fa757aed4b58447d2cba83d0006a21ee4738b217fc/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f4e657665726d696c6c652f456d61696c3f6272616e63683d6d6173746572)](https://bettercodehub.com/)

Overview
--------

[](#overview)

A simple PHP class for email. Please keep in mind this library *doesn't* send mails, you have to extend these classes with a send function.

Compatibility
-------------

[](#compatibility)

This library has been tested for **PHP 7.3 and higher**

Installation
------------

[](#installation)

Just use composer in your project:

```
composer require lianhua/email

```

If you don't use composer, clone or download this repository, all you need is inside the *src* directory.

Usage
-----

[](#usage)

### Creating an email

[](#creating-an-email)

You can create an email by using the constructor

```
$email = new \Lianhua\Email\Email();
```

### Setting the message

[](#setting-the-message)

You can set a TXT or a HTML message with a method. You can also set a special message for disabled people. You also can set a subject.

```
// Set messages
$email->setMessage("Welcome!");
$email->setAlternateContent("Welcome, screen reader user");
$email->setSubject("Welcome message");

// Get messages
$email->getMessage(); // "Welcome!"
$email->getAlternateContent(); // "Welcome, screen reader user"
$email->getSubject(); // "Welcome message"
```

### Addresses

[](#addresses)

You can set the addresses with Email methods by providing an EmailAddress object.

You can only have one "From" and "Reply" addresses and as many "To", "Cc" and "Bcc". The address format is checked before adding it.

```
$address = new \Lianhua\Email\EmailAddress("address@example.com", "Recipient Name");

// Set addresses
$email->setFrom($address);
$email->setReply($address);
$email->addTo($address);
$email->addCc($address);
$email->addBcc($address);

// Get addresses
$email->getFrom(); // $address
$email->getReply(); // $address
$email->getTo(); // [$address]
$email->getCc(); // [$address]
$email->getBcc(); // [$address]
```

You can delete all addresses for "To", "Cc" and "Bcc" with the clear\* functions

```
$email->clearTo();
$email->clearCc();
$email->clearBcc();
```

### Attachements

[](#attachements)

You can add and delete attachments with Email methods. The file existence is checked before.

```
// Add attachments
$email->addAttachment("/tmp/A.pdf");
$email->addAttachment("/tmp/B.pdf");

// Get attachments
$email->getAttachments(); // ["/tmp/A.pdf", "/tmp/B.pdf"]

// Delete attachments
$email->clearAttachments();
```

### Headers

[](#headers)

You can set cutom headers

```
// Add headers
$email->addHeader("X-HEADER", "WELCOME");
$email->addHeader("X-HEADER-2", "BIENVENUE");

// Get headers
$email->getHeaders(); // ["X-HEADER" => "WELCOME", "X-HEADER-2" => "BIENVENUE"]

// Delete headers
$email->clearHeaders();
```

### Advanced

[](#advanced)

#### Check DNS

[](#check-dns)

You can ask for a DNS MX record check before adding addresses.

```
// Set parameter
$email->setCheckDns(true);

// Add address
$email->addTo(new \Lianhua\Email\EmailAddress("test@google.com")); // Valid
$email->addTo(new \Lianhua\Email\EmailAddress("test@google.con")); // Not valid
```

#### Return values

[](#return-values)

When you use an address function, you can see if the input address had been added

```
$email->addTo(new \Lianhua\Email\EmailAddress("test@google.com")); // \Lianhua\Email\Email::NO_ERRORS
$email->addTo(new \Lianhua\Email\EmailAddress("test.google.com")); // \Lianhua\Email\Email::ERROR_EMAIL_FORMAT

// If you enabled DNS check
$email->addTo(new \Lianhua\Email\EmailAddress("test@google.con")); // \Lianhua\Email\Email::ERROR_EMAIL_DNS_CHECK
```

You can see if the attachment had been added too

```
// Add attachments
$email->addAttachment("/tmp/A.pdf"); // \Lianhua\Email\Email::NO_ERRORS
$email->addAttachment("/tmp/kjbfkkqsd"); // \Lianhua\Email\Email::ERROR_FILE_NOT_FOUND
$email->addAttachment("/tmp"); // \Lianhua\Email\Email::ERROR_FILE_IS_DIRECTORY
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

4

Last Release

2295d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38858480?v=4)[Camille Nevermind](/maintainers/Nevermille)[@nevermille](https://github.com/nevermille)

---

Top Contributors

[![nevermille](https://avatars.githubusercontent.com/u/38858480?v=4)](https://github.com/nevermille "nevermille (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lianhua-email/health.svg)

```
[![Health](https://phpackages.com/badges/lianhua-email/health.svg)](https://phpackages.com/packages/lianhua-email)
```

###  Alternatives

[maize-tech/laravel-email-domain-rule

Laravel Email Domain Rule

612.0k](/packages/maize-tech-laravel-email-domain-rule)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)

PHPackages © 2026

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