Skip to content

Commit c068c93

Browse files
committed
chore: update readme
1 parent 8f2434d commit c068c93

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

README.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,73 @@
66
<br><br>
77
</p>
88

9-
# Leaf PHP
9+
# Leaf Mail v2
1010

1111
[![Latest Stable Version](https://poser.pugx.org/leafs/mail/v/stable)](https://packagist.org/packages/leafs/mail)
1212
[![Total Downloads](https://poser.pugx.org/leafs/mail/downloads)](https://packagist.org/packages/leafs/mail)
1313
[![License](https://poser.pugx.org/leafs/mail/license)](https://packagist.org/packages/leafs/mail)
1414

15-
Leaf's mail template engine packaged as a serve-yourself module.
15+
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.
16+
17+
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.
1618

1719
## Installation
1820

19-
You can easily install Leaf using [Composer](https://getcomposer.org/).
21+
You can install leaf mail using the leaf cli:
22+
23+
```bash
24+
leaf install mail
25+
```
26+
27+
or with composer:
2028

2129
```bash
2230
composer require leafs/mail
2331
```
2432

25-
## View Leaf's docs [here](https://leafphp.netlify.app/#/)
33+
## Basic Usage
34+
35+
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.
36+
37+
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.
38+
39+
Note that you need to setup the connection to your mail server using the Leaf\Mail\Mailer class before sending your emails.
40+
41+
### Configure your mailer
42+
43+
```php
44+
use Leaf\Mail\Mailer;
45+
use PHPMailer\PHPMailer\PHPMailer;
46+
47+
...
48+
49+
Mailer::connect([
50+
'host' => 'smtp.mailtrap.io',
51+
'port' => 2525,
52+
'security' => PHPMailer::ENCRYPTION_STARTTLS,
53+
'auth' => [
54+
'username' => 'MAILTRAP_USERNAME',
55+
'password' => 'MAILTRAP_PASSWORD'
56+
]
57+
]);
58+
```
59+
60+
### Send your mails
61+
62+
```php
63+
mailer()
64+
->create([
65+
'subject' => 'Leaf Mail Test',
66+
'body' => 'This is a test mail from Leaf Mail using gmail',
67+
68+
// next couple of lines can be skipped if you
69+
// set defaults in the Mailer config
70+
'recipientEmail' => '[email protected]',
71+
'recipientName' => 'First Last',
72+
'senderName' => 'Leaf Mail',
73+
'senderEmail' => '[email protected]',
74+
])
75+
->send();
76+
```
2677

27-
Built with ❤ by [**Mychi Darko**](https://mychi.netlify.app)
78+
**v2 is still WIP, we aim to release it soon. You can still use it by running `composer require leafs/leaf:dev-next`**

0 commit comments

Comments
 (0)