summaryrefslogtreecommitdiff
path: root/app/Job/EmailJob.php
blob: c6eb500a58ae3e743e64d1fe73e32e631968a3ec (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 $recipientEmail
     * @param  string $recipientName
     * @param  string $subject
     * @param  string $html
     * @param  string $authorName
     * @param  string $authorEmail
     * @return $this
     */
    public function withParams($recipientEmail, $recipientName, $subject, $html, $authorName, $authorEmail)
    {
        $this->jobParams = array($recipientEmail, $recipientName, $subject, $html, $authorName, $authorEmail);
        return $this;
    }

    /**
     * Execute job
     *
     * @access public
     * @param  string $recipientEmail
     * @param  string $recipientName
     * @param  string $subject
     * @param  string $html
     * @param  string $authorName
     * @param  string $authorEmail
     */
    public function execute($recipientEmail, $recipientName, $subject, $html, $authorName, $authorEmail)
    {
        $transport = $this->helper->mail->getMailTransport();
        $startTime = microtime(true);

        $this->logger->debug(__METHOD__.' Sending email to: '.$recipientEmail.' using transport: '.$transport);

        $this->emailClient
            ->getTransport($transport)
            ->sendEmail($recipientEmail, $recipientName, $subject, $html, $authorName, $authorEmail);

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