summaryrefslogtreecommitdiff
path: root/app/Job/EmailJob.php
blob: 2da3ca2a35d637b71dab01f42577882d347e4bc8 (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
55
<?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)
    {
        $transport = $this->helper->mail->getMailTransport();
        $this->logger->debug(__METHOD__.' Sending email to: '.$email.' using transport: '.$transport);
        $startTime = microtime(true);

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

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