blob: 0fc278d146dae37820f9bd86b49953ee6657a6e6 (
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
56
57
58
59
60
61
62
63
64
65
66
|
<?php
namespace Kanboard\Core\Mail\Transport;
use Swift_Message;
use Swift_Mailer;
use Swift_MailTransport;
use Swift_TransportException;
use Kanboard\Core\Base;
use Kanboard\Core\Mail\ClientInterface;
/**
* PHP Mail Handler
*
* @package Kanboard\Core\Mail\Transport
* @author Frederic Guillot
*/
class Mail extends Base implements 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 = '')
{
try {
$message = Swift_Message::newInstance()
->setSubject($subject)
->setFrom($this->helper->mail->getMailSenderAddress(), $authorName)
->setTo(array($recipientEmail => $recipientName));
$headers = $message->getHeaders();
// See https://tools.ietf.org/html/rfc3834#section-5
$headers->addTextHeader('Auto-Submitted', 'auto-generated');
if (! empty($authorEmail)) {
$message->setReplyTo($authorEmail);
}
$message->setBody($html, 'text/html');
Swift_Mailer::newInstance($this->getTransport())->send($message);
} catch (Swift_TransportException $e) {
$this->logger->error($e->getMessage());
}
}
/**
* Get SwiftMailer transport
*
* @access protected
* @return \Swift_Transport
*/
protected function getTransport()
{
return Swift_MailTransport::newInstance();
}
}
|