Skip to content

Commit 0df6d0a

Browse files
committed
added readme
1 parent 9587ebd commit 0df6d0a

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

README.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Sineld - Onesignal Mail for Laravel
2+
3+
This is a wrapper for Onesignal Email for Laravel.
4+
You can send e-mails in your project just like you usually do with Laravel's native mailers, the package makes sure the e-mails are send via the Onesignal Mail API using your Onesignal Email account.
5+
6+
## Requires
7+
Laravel version 9.0, 10.00, 11.0 or higher.
8+
9+
### Installation ###
10+
11+
* Step 1: Install package via composer.
12+
13+
```bash
14+
composer require sineld/onesignal-mail
15+
```
16+
17+
* Step 2: Add your account and API keys to your **.env file**.
18+
```
19+
ONESIGNAL_MAIL_URL=https://onesignal.com/api/v1/notifications
20+
ONESIGNAL_MAIL_API=<Your API KEY>
21+
ONESIGNAL_MAIL_APP_ID=<Your APP ID>
22+
```
23+
24+
* Step 3: Update **MAIL_MAILER** with 'onesignal-mail' in your **.env file**.
25+
```
26+
MAIL_MAILER=onesignal-mail
27+
```
28+
29+
* Step 4: Add this new mailer to your **config/mail.php*** file.
30+
```php
31+
'mailers' => [
32+
...
33+
'onesignal-mail' => [
34+
'transport' => 'onesignal-mail',
35+
'api_url' => env('ONESIGNAL_MAIL_URL'),
36+
'api_key' => env('ONESIGNAL_MAIL_API'),
37+
'app_id' => env('ONESIGNAL_MAIL_APP_ID'),
38+
],
39+
...
40+
],
41+
```
42+
43+
* Step 5: In your **config/app.php** (Laravel 11+ **bootstrap/providers.php**) file go to your providers array and add the following package provider:
44+
```php
45+
'providers' => [
46+
/*
47+
* Laravel Framework Service Providers...
48+
*/
49+
...
50+
\Sineld\OneSignalMail\OneSignalMailServiceProvider::class
51+
...
52+
],
53+
```
54+
55+
### Usage ###
56+
```php
57+
// Create **contact.blade.php** file under **resources/views** folder with this content:
58+
<p>Hello {{ $name }}, ({{ $email }})</p>
59+
60+
<p>{{ $subject }}</p>
61+
62+
<p>{{ $body }}</p>
63+
64+
// Send your email
65+
$data = [
66+
'name' => 'Recieptant Name',
67+
'email' => '[email protected]',
68+
'subject' => 'Hello World!',
69+
'body' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
70+
];
71+
72+
Mail::send('contact', $data, function ($mail) use ($data) {
73+
$mail
74+
->to(
75+
$data['email'],
76+
$data['name']
77+
)
78+
->subject($data['subject'])
79+
// ->replyTo('[email protected]')
80+
;
81+
});
82+
83+
// or use mailables!
84+
```
85+
86+
Read Laravel's documentation on how to send E-mails with the Laravel Framework.
87+
88+
https://laravel.com/docs/master/mail

0 commit comments

Comments
 (0)