summaryrefslogtreecommitdiff
path: root/app/Core/EmailClient.php
blob: 980f5acc6ad593c437250e035c256c314c3534f7 (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
<?php

namespace Core;

/**
 * Mail client
 *
 * @package  core
 * @author   Frederic Guillot
 */
class EmailClient extends Base
{
    /**
     * Send a HTML email
     *
     * @access public
     * @param  string  $email
     * @param  string  $name
     * @param  string  $subject
     * @param  string  $html
     */
    public function send($email, $name, $subject, $html)
    {
        $this->container['logger']->debug('Sending email to '.$email.' ('.MAIL_TRANSPORT.')');

        $start_time = microtime(true);
        $author = 'Kanboard';

        if (Session::isOpen() && $this->userSession->isLogged()) {
            $author = e('%s via Kanboard', $this->user->getFullname($this->session['user']));
        }

        switch (MAIL_TRANSPORT) {
            case 'postmark':
                $this->postmark->sendEmail($email, $name, $subject, $html, $author);
                break;
            default:
                $this->smtp->sendEmail($email, $name, $subject, $html, $author);
        }

        $this->container['logger']->debug('Email sent in '.round(microtime(true) - $start_time, 6).' seconds');
    }
}