https://github.com/jornatf/msgraph-mailer
A Laravel Package to send emails with Microsoft Graph API.
https://github.com/jornatf/msgraph-mailer
api laravel laravel-package microsoft-graph microsoft-graph-api php send-mail
Last synced: 3 months ago
JSON representation
A Laravel Package to send emails with Microsoft Graph API.
- Host: GitHub
- URL: https://github.com/jornatf/msgraph-mailer
- Owner: jornatf
- License: mit
- Created: 2023-04-06T12:32:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-09T01:04:47.000Z (over 1 year ago)
- Last Synced: 2025-02-08T12:11:17.514Z (4 months ago)
- Topics: api, laravel, laravel-package, microsoft-graph, microsoft-graph-api, php, send-mail
- Language: PHP
- Homepage: https://packagist.org/packages/jornatf/msgraph-mailer
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Msgraph Mailer
[](https://packagist.org/packages/jornatf/msgraph-mailer)
[](https://github.com/jornatf/msgraph-mailer/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/jornatf/msgraph-mailer/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/jornatf/msgraph-mailer)A Laravel Package to send emails with [Microsoft Graph API](https://learn.microsoft.com/en-us/graph/use-the-api).
> #### If you like this package you can [Buy me a Coffee](https://www.buymeacoffee.com/jornatf) ☕️
## Installation
### Via composer:
```bash
composer require jornatf/msgraph-mailer
```### Prerequisites:
Add your [Microsoft Graph](https://learn.microsoft.com/en-us/graph/overview) credentials in the `.env` file:
```
MSGRAPH_CLIENT_ID=your_client_id
MSGRAPH_SECRET_ID=your_secret_id
MSGRAPH_TENANT_ID=your_tenant_id
```## Usage
### Example:
> This example shows you how to use the basic methods required to send an email.
```php
to(['John Doe:[email protected]', '[email protected]', $otherRecipients])
->subject('A simple email')
->body('Send a simple email to one recipient.
')
->send();
} catch (\Exception $e) {
return $e->getMessage();
}return "Email sended!";
}
}
```### Available methods:
```php
to(array $toRecipient);
$msgraph->subject(string $subject);
$msgraph->content(string $contentHTML);// You can add Cc and/or bcc with the same way (optionally):
$msgraph->cc(array $ccRecipient);
$msgraph->bcc(array $bccRecipient);// Optionally, you can add one or many attachments:
$msgraph->addAttachment(array $attachment = [
'name' => $filename,
'contentType' => $contentType,
'content' => $contentBytes
]);
// and repeat if you have many attachments.// Last, send your mail:
$msgraph->send();
```## Testing
```bash
composer test
```## Changelog
> Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
> Feel free to contribute to this project to improve with new features or fix bugs 👍
## Credits
- [Jordan](https://github.com/jornatf)
- [All Contributors](../../contributors)## License
The MIT License (MIT).
> Please see [License File](LICENSE.md) for more information.