summaryrefslogtreecommitdiff
path: root/app/Job/EmailJob.php
blob: 9293a1d498cb4af05007931a2ccc25dd40090afd (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
52
53
54
<?php

namespace Kanboard\Job;

/**
 * Class EmailJob
 *
 * @package Kanboard\Job
 * @author  Frederic Guillot
 */
class EmailJob extends BaseJob
{
    /**
     * Set job parameters
     *
     * @access public
     * @param  string $email
     * @param  string $name
     * @param  string $subject
     * @param  string $html
     * @param  string $author
     * @return $this
     */
    public function withParams($email, $name, $subject, $html, $author)
    {
        $this->jobParams = array($email, $name, $subject, $html, $author);
        return $this;
    }

    /**
     * Execute job
     *
     * @access public
     * @param  string $email
     * @param  string $name
     * @param  string $subject
     * @param  string $html
     * @param  string $author
     */
    public function execute($email, $name, $subject, $html, $author)
    {
        $this->logger->debug(__METHOD__.' Sending email to '.$email.' via '.MAIL_TRANSPORT);
        $startTime = microtime(true);

        $this->emailClient
            ->getTransport(MAIL_TRANSPORT)
            ->sendEmail($email, $name, $subject, $html, $author)
        ;

        if (DEBUG) {
            $this->logger->debug('Email sent in '.round(microtime(true) - $startTime, 6).' seconds');
        }
    }
}