summaryrefslogtreecommitdiff
path: root/doc/en_US/plugin-mail-transports.markdown
blob: f3f9efc6f8ff850b5ffe9f2b614155a99dea12d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Plugin: Add Mail Transport
==========================

By default Kanboard supports 3 standards mail transports:

- Mail (PHP mail function)
- Smtp
- Sendmail command

With the plugin API you can add a driver for any email provider.
For example, your plugin can add a mail transport for a provider that uses an HTTP API.

Implementation
--------------

Your plugin must implement the interface `Kanboard\Core\Mail\ClientInterface` and extends from `Kanboard\Core\Base`.

The only method you need to implement is `sendEmail()`:

```php
interface ClientInterface
{
    /**
     * Send a HTML email
     *
     * @access public
     * @param  string $recipientEmail
     * @param  string $recipientName
     * @param  string $subject
     * @param  string $html
     * @param  string $authorName
     * @param  string $authorEmail
     */
    public function sendEmail($recipientEmail, $recipientName, $subject, $html, $authorName, $authorEmail = '');
}
```

To register your new mail transport, use the method `setTransport($transport, $class)` from the class `Kanboard\Core\Mail\Client`:

```php
$this->emailClient->setTransport('myprovider', '\Kanboard\Plugin\MyProvider\MyEmailHandler');
```

The second argument contains the absolute name space of your concrete class.

Examples of mail transport plugins
----------------------------------

- [Sendgrid](https://github.com/kanboard/plugin-sendgrid)
- [Mailgun](https://github.com/kanboard/plugin-mailgun)
- [Postmark](https://github.com/kanboard/plugin-postmark)