-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f2434d
commit c068c93
Showing
1 changed file
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,73 @@ | |
<br><br> | ||
</p> | ||
|
||
# Leaf PHP | ||
# Leaf Mail v2 | ||
|
||
[![Latest Stable Version](https://poser.pugx.org/leafs/mail/v/stable)](https://packagist.org/packages/leafs/mail) | ||
[![Total Downloads](https://poser.pugx.org/leafs/mail/downloads)](https://packagist.org/packages/leafs/mail) | ||
[![License](https://poser.pugx.org/leafs/mail/license)](https://packagist.org/packages/leafs/mail) | ||
|
||
Leaf's mail template engine packaged as a serve-yourself module. | ||
Mailing in PHP apps has always been seen as a daunting task. Leaf Mail provides a simple, straightforward and efficient email API that is built on the widely used PHPMailer Library component. | ||
|
||
With Leaf Mail, you can easily send emails using various drivers and services such as SMTP, Mailgun, SendGrid, Amazon SES, and sendmail. This flexibility enables you to swiftly begin sending emails through a preferred local or cloud-based service. | ||
|
||
## Installation | ||
|
||
You can easily install Leaf using [Composer](https://getcomposer.org/). | ||
You can install leaf mail using the leaf cli: | ||
|
||
```bash | ||
leaf install mail | ||
``` | ||
|
||
or with composer: | ||
|
||
```bash | ||
composer require leafs/mail | ||
``` | ||
|
||
## View Leaf's docs [here](https://leafphp.netlify.app/#/) | ||
## Basic Usage | ||
|
||
Leaf Mail provides a Mailer class that is responsible for validating and sending emails. This class handles the connection to your mail server, the configuration for how to send your emails and the actual sending of emails. | ||
|
||
It also provides a mailer() method that is responsible for creating and formatting emails. Most of the time, you'll be using the mailer() method to create and send emails. | ||
|
||
Note that you need to setup the connection to your mail server using the Leaf\Mail\Mailer class before sending your emails. | ||
|
||
### Configure your mailer | ||
|
||
```php | ||
use Leaf\Mail\Mailer; | ||
use PHPMailer\PHPMailer\PHPMailer; | ||
|
||
... | ||
|
||
Mailer::connect([ | ||
'host' => 'smtp.mailtrap.io', | ||
'port' => 2525, | ||
'security' => PHPMailer::ENCRYPTION_STARTTLS, | ||
'auth' => [ | ||
'username' => 'MAILTRAP_USERNAME', | ||
'password' => 'MAILTRAP_PASSWORD' | ||
] | ||
]); | ||
``` | ||
|
||
### Send your mails | ||
|
||
```php | ||
mailer() | ||
->create([ | ||
'subject' => 'Leaf Mail Test', | ||
'body' => 'This is a test mail from Leaf Mail using gmail', | ||
|
||
// next couple of lines can be skipped if you | ||
// set defaults in the Mailer config | ||
'recipientEmail' => '[email protected]', | ||
'recipientName' => 'First Last', | ||
'senderName' => 'Leaf Mail', | ||
'senderEmail' => '[email protected]', | ||
]) | ||
->send(); | ||
``` | ||
|
||
Built with ❤ by [**Mychi Darko**](https://mychi.netlify.app) | ||
**v2 is still WIP, we aim to release it soon. You can still use it by running `composer require leafs/leaf:dev-next`** |