Introduce an use_sendmail option
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
7305c0f89c
commit
d6c2f01457
@ -42,7 +42,7 @@ $is_admin = false;
|
||||
$logService = new LogService();
|
||||
$pollService = new PollService($connect, $logService);
|
||||
$inputService = new InputService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService);
|
||||
$securityService = new SecurityService();
|
||||
|
||||
|
@ -28,7 +28,7 @@ include_once __DIR__ . '/../app/inc/init.php';
|
||||
|
||||
$logService = new LogService();
|
||||
$sessionService = new SessionService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$pollService = new PollService($connect, $logService);
|
||||
|
||||
$result = false;
|
||||
|
@ -50,7 +50,7 @@ $logService = new LogService();
|
||||
$pollService = new PollService($connect, $logService);
|
||||
$adminPollService = new AdminPollService($connect, $pollService, $logService);
|
||||
$inputService = new InputService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService);
|
||||
$sessionService = new SessionService();
|
||||
|
||||
|
@ -8,18 +8,39 @@ class MailService {
|
||||
|
||||
const MAILSERVICE_KEY = 'mailservice';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $smtp_allowed;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $smtp_options = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $use_sendmail;
|
||||
|
||||
/**
|
||||
* @var LogService
|
||||
*/
|
||||
private $logService;
|
||||
|
||||
function __construct($smtp_allowed, $smtp_options = []) {
|
||||
/**
|
||||
* MailService constructor.
|
||||
* @param $smtp_allowed
|
||||
* @param array $smtp_options
|
||||
* @param bool $use_sendmail
|
||||
*/
|
||||
public function __construct($smtp_allowed, $smtp_options = [], $use_sendmail = false) {
|
||||
$this->logService = new LogService();
|
||||
$this->smtp_allowed = $smtp_allowed;
|
||||
if (true === is_array($smtp_options)) {
|
||||
$this->smtp_options = $smtp_options;
|
||||
}
|
||||
$this->use_sendmail = $use_sendmail;
|
||||
}
|
||||
|
||||
public function isValidEmail($email) {
|
||||
@ -82,7 +103,11 @@ class MailService {
|
||||
* @param PHPMailer $mailer
|
||||
*/
|
||||
private function configureMailer(PHPMailer $mailer) {
|
||||
$mailer->isSMTP();
|
||||
if ($this->use_sendmail) {
|
||||
$mailer->isSendmail();
|
||||
} else {
|
||||
$mailer->isSMTP();
|
||||
}
|
||||
|
||||
$available_options = [
|
||||
'host' => 'Host',
|
||||
|
@ -31,7 +31,7 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
/*---------*/
|
||||
$logService = new LogService();
|
||||
$pollService = new PollService($connect, $logService);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$purgeService = new PurgeService($connect, $logService);
|
||||
$sessionService = new SessionService();
|
||||
|
||||
|
@ -31,7 +31,7 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
/*---------*/
|
||||
$logService = new LogService();
|
||||
$pollService = new PollService($connect, $logService);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$purgeService = new PurgeService($connect, $logService);
|
||||
$inputService = new InputService();
|
||||
$sessionService = new SessionService();
|
||||
|
@ -28,7 +28,7 @@ include_once __DIR__ . '/app/inc/init.php';
|
||||
/* -------- */
|
||||
$logService = new LogService();
|
||||
$pollService = new PollService($connect, $logService);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
|
||||
/* PAGE */
|
||||
/* ---- */
|
||||
|
@ -58,7 +58,7 @@ $selectedNewVotes = [];
|
||||
$logService = new LogService();
|
||||
$pollService = new PollService($connect, $logService);
|
||||
$inputService = new InputService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options']);
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService);
|
||||
$securityService = new SecurityService();
|
||||
$sessionService = new SessionService();
|
||||
|
@ -101,7 +101,8 @@ const DEMO_POLL_NUMBER_VOTES = 10;
|
||||
// Config
|
||||
$config = [
|
||||
/* general config */
|
||||
'use_smtp' => true, // use email for polls creation/modification/responses notification
|
||||
'use_smtp' => true, // use email for polls creation/modification/responses notification (uses smtp only if `use_sendmail` is disabled)
|
||||
'use_sendmail' => false, // use sendmail instead of smtp
|
||||
'smtp_options' => [
|
||||
'host' => 'localhost', // SMTP server (you could add many servers (main and backup for example) : use ";" like separator
|
||||
'auth' => false, // Enable SMTP authentication
|
||||
|
Loading…
Reference in New Issue
Block a user