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

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

asgard/email
============

v0.3.1(10y ago)029MITPHPPHP &gt;=5.5.9

Since Sep 9Pushed 8y agoCompare

[ Source](https://github.com/asgardphp/email)[ Packagist](https://packagist.org/packages/asgard/email)[ RSS](/packages/asgard-email/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

\#Email

[![Build Status](https://camo.githubusercontent.com/5c04af40e190c4477d7b708dbca6fbe14bc6445eb79ff493161b6db10cd7638a/68747470733a2f2f7472617669732d63692e6f72672f6173676172647068702f656d61696c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/asgardphp/email)

- [Installation](#installation)
- [Usage in the Asgard Framework](#usage-asgard)
- [Usage outside the Asgard Framework](#usage-outside)
- [Send an email](#send)
- [Attach files](#files)
- [Attach images](#images)
- [Fake mail](#fake)

\##Installation **If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries.**

```
composer require asgard/email 0.*

```

\##Usage in the Asgard Framework

\###Configuration

In a configuration file, in config/, add:

```
#smtp
email:
	driver: Asgard\Email\SwiftEmail
	transport => smtp
	username  => ...
	password  => ...
	security  => ssl #or null
	host      => ...
	port      => ...
#sendmail
email:
	driver: Asgard\Email\SwiftEmail
	transport => sendmail
	command  => ...
#mail()
email:
	driver: Asgard\Email\SwiftEmail

```

\###Service

```
$email = $container['email'];

```

The [container](docs/container) is often accessible as a method parameter or through a [ContainerAware](docs/container#containeraware) object. You can also use the [singleton](docs/container#usage-outside) but it is not recommended.

\##Usage outside the Asgard Framework

\###Configuration

```
#smtp
$config = [
	'transport' => 'smtp',
	'username'  => '...',
	'password'  => '...',
	'security'  => 'ssl', #or null
	'host'      => '...',
	'port'      => '...',
];
#sendmail
$config = [
	'transport' => 'sendmail',
	'command'  => '...',
];
#mail()
$config = [];

```

\###Instance

```
$email = new \Asgard\Email\SwiftEmail;
$email->transport($config);

```

\##Sending an email

```
$email->send(function($message) {
	$message->to('bob@example.com');
	$message->from('joe@example.com');
	$message->cc('joe@example.com');
	$message->bcc('joe@example.com');
	$message->text('hello!');
	$message->html('hello!');
});

```

$message inherits \\Swift\_Message so you can use any of its methods as well. [See its documentation](http://swiftmailer.org/docs/messages.html).

\##Attaching files

Directly attach a file:

```
$email->send(function($message) {
	//...
	$message->attachFile('/path/to/file.jpg', 'myhouse.jpg', 'image/jpeg');
});

```

Or data:

```
$email->send(function($message) {
	//...
	$message->attachData($data, 'myhouse.jpg', 'image/jpeg');
});

```

\##Embedding images

Directly embed an image:

```
$email->send(function($message) {
	//...
	$message->html('Hello! See my house '.$message->embedFile('/path/to/file.jpg', 'myhouse.jpg', 'image/jpeg'));
});

```

Or data:

```
$email->send(function($message) {
	//...
	$message->html('Hello! See my house '.$message->embedData($data, 'myhouse.jpg', 'image/jpeg'));
});

```

\##Fake mail

For tests and development, you might want to use fake mails, not to send real emails. Fake mails are simply written on a local.

**Configuration**

```
email:
	driver: Asgard\Email\FakeEmail
	file: storage/email.txt

```

Besides this, the usage is the same as for other emails.

\###Contributing

Please submit all issues and pull requests to the [asgardphp/asgard](http://github.com/asgardphp/asgard) repository.

### License

[](#license)

The Asgard framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

4

Last Release

3657d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4.0

v0.3.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/352850?v=4)[leyou](/maintainers/leyou)[@leyou](https://github.com/leyou)

---

Top Contributors

[![h0gar](https://avatars.githubusercontent.com/u/439138?v=4)](https://github.com/h0gar "h0gar (44 commits)")

### Embed Badge

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

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

###  Alternatives

[cspoo/swiftmailer-mailgun-bundle

Swiftmailer Mailgun bundle

1031.1M](/packages/cspoo-swiftmailer-mailgun-bundle)[wildbit/swiftmailer-postmark

A Swiftmailer Transport for Postmark.

542.8M6](/packages/wildbit-swiftmailer-postmark)[openbuildings/swiftmailer-css-inliner

Inline the css of your html emails

69401.9k3](/packages/openbuildings-swiftmailer-css-inliner)[mailjet/mailjet-swiftmailer

A SwiftMailer transport implementation for Mailjet

261.2M9](/packages/mailjet-mailjet-swiftmailer)[phalcon-ext/mailer

Mailer component as wrapper over SwiftMailer for Phalcon.

39196.9k2](/packages/phalcon-ext-mailer)[openbuildings/postmark

Swiftmailer Transport Class for Postmark

15369.8k2](/packages/openbuildings-postmark)

PHPackages © 2026

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