https://github.com/kisphp/simple-mail
Simple and quick solution to send emails to users with a minimal configuration
https://github.com/kisphp/simple-mail
Last synced: about 1 year ago
JSON representation
Simple and quick solution to send emails to users with a minimal configuration
- Host: GitHub
- URL: https://github.com/kisphp/simple-mail
- Owner: kisphp
- License: mit
- Created: 2016-03-12T10:39:44.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-08-14T13:54:58.000Z (over 6 years ago)
- Last Synced: 2025-01-04T02:56:16.171Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Kisphp Simple mailer
[](https://travis-ci.org/kisphp/simple-mail)
[](https://codecov.io/github/kisphp/simple-mail?branch=master)
[](https://packagist.org/packages/kisphp/simple-mail)
[](https://packagist.org/packages/kisphp/simple-mail)
[](https://packagist.org/packages/kisphp/simple-mail)
[](https://packagist.org/packages/kisphp/simple-mail)
Quick send emails with swift mailer for your website with a very simple implementation.
By default is configured to send through google.
## Installation
```bash
composer require kisphp/simple-mail
```
## Configuration
If you already use composer into your project, then the required libraries will be automatically included.
Other way you'll have to include autoloader into your php file:
```php
require_once '/path/to/vendor/autoload.php';
```
First step you need to do, is to create a Configuration class that will implement `Kisphp\Mail\MailConfigInterface;`.
```php
'User name 1',
'user_2@example.com' => 'User name 2',
];
$subject = 'Testing mail';
$htmlMessage = 'this is my message for you';
// compose email
$messenger->createMailMessage($recipients, $subject, $htmlMessage);
// send the email and get the number of how many emails were sent
$emailsSent = $messenger->send();
```
## Change mail transport type
To change the transport type you'll have to extend the createMailTransport method from Messenger class:
```php
transport = \Swift_MailTransport::newInstance();
return $this;
}
}
class DemoMailerFactory extends AbstractMailerFactory
{
// createMailConfig method here
/**
* @param MailConfigInterface $config
*
* @return MessengerInterface
*/
public function createMessenger(MailConfigInterface $config)
{
return new ProjectMessenger($config);
}
}
// and load this class in your project
$messenger = new ProjectMessenger($config);
```
More details can be seen here: [SwiftMailer Sending](http://swiftmailer.org/docs/sending.html)