看板初始化提交
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?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));
|
||||
|
||||
if (! empty(MAIL_BCC)) {
|
||||
$message->setBcc(MAIL_BCC);
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Core\Mail\Transport;
|
||||
|
||||
use Swift_SendmailTransport;
|
||||
|
||||
/**
|
||||
* PHP Mail Handler
|
||||
*
|
||||
* @package Kanboard\Core\Mail\Transport
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Sendmail extends Mail
|
||||
{
|
||||
/**
|
||||
* Get SwiftMailer transport
|
||||
*
|
||||
* @access protected
|
||||
* @return \Swift_Transport
|
||||
*/
|
||||
protected function getTransport()
|
||||
{
|
||||
return Swift_SendmailTransport::newInstance(MAIL_SENDMAIL_COMMAND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Core\Mail\Transport;
|
||||
|
||||
use Swift_SmtpTransport;
|
||||
|
||||
/**
|
||||
* PHP Mail Handler
|
||||
*
|
||||
* @package Kanboard\Core\Mail\Transport
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class Smtp extends Mail
|
||||
{
|
||||
/**
|
||||
* Get SwiftMailer transport
|
||||
*
|
||||
* @access protected
|
||||
* @return \Swift_Transport
|
||||
*/
|
||||
protected function getTransport()
|
||||
{
|
||||
$transport = Swift_SmtpTransport::newInstance(MAIL_SMTP_HOSTNAME, MAIL_SMTP_PORT);
|
||||
$transport->setUsername(MAIL_SMTP_USERNAME);
|
||||
$transport->setPassword(MAIL_SMTP_PASSWORD);
|
||||
if (!is_null(MAIL_SMTP_HELO_NAME)) {
|
||||
$transport->setLocalDomain(MAIL_SMTP_HELO_NAME);
|
||||
}
|
||||
$transport->setEncryption(MAIL_SMTP_ENCRYPTION);
|
||||
|
||||
if (HTTP_VERIFY_SSL_CERTIFICATE === false) {
|
||||
$transport->setStreamOptions(array(
|
||||
'ssl' => array(
|
||||
'allow_self_signed' => true,
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
return $transport;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user