Ivan - Add smtp settings [skip ci]
This commit is contained in:
parent
3f01526814
commit
d23fba451e
|
@ -23,7 +23,12 @@ class InitSettingsController extends Controller {
|
||||||
|
|
||||||
private function storeGlobalSettings() {
|
private function storeGlobalSettings() {
|
||||||
$this->storeSettings([
|
$this->storeSettings([
|
||||||
'language' => 'en'
|
'language' => 'en',
|
||||||
|
'no-reply-email' => 'noreply@opensupports.com',
|
||||||
|
'smtp-host' => 'localhost',
|
||||||
|
'smtp-port' => 7070,
|
||||||
|
'smtp-user' => '',
|
||||||
|
'smtp-pass' => '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,13 @@ class MailSender {
|
||||||
|
|
||||||
private $mailOptions = [];
|
private $mailOptions = [];
|
||||||
|
|
||||||
//TODO: Add real initial options when Settings class is available
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->mailOptions['from'] = 'noreply@opensupports.com';
|
$this->mailOptions['from'] = Setting::getSetting('no-reply-email');
|
||||||
|
|
||||||
//SMTP Options
|
$this->mailOptions['smtp-host'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_host'] = 'localhost';
|
$this->mailOptions['smtp-port'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_port'] = 7070;
|
$this->mailOptions['smtp-user'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_user'] = '';
|
$this->mailOptions['smtp-pass'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_pass'] = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTemplate($type, $config) {
|
public function setTemplate($type, $config) {
|
||||||
|
@ -29,14 +27,12 @@ class MailSender {
|
||||||
$mailer->Subject = $this->mailOptions['subject'];
|
$mailer->Subject = $this->mailOptions['subject'];
|
||||||
$mailer->Body = $this->mailOptions['body'];
|
$mailer->Body = $this->mailOptions['body'];
|
||||||
|
|
||||||
//$mailer->SMTPDebug = 3;
|
|
||||||
$mailer->isSMTP();
|
$mailer->isSMTP();
|
||||||
$mailer->SMTPAuth = true;
|
$mailer->SMTPAuth = true;
|
||||||
$mailer->Host = $this->mailOptions['smtp_host'];
|
$mailer->Host = $this->mailOptions['smtp-host'];
|
||||||
$mailer->Port = $this->mailOptions['smtp_port'];
|
$mailer->Port = $this->mailOptions['smtp-port'];
|
||||||
$mailer->Username = $this->mailOptions['smtp_user'];
|
$mailer->Username = $this->mailOptions['smtp-user'];
|
||||||
$mailer->Password = $this->mailOptions['smtp_pass'];
|
$mailer->Password = $this->mailOptions['smtp-pass'];
|
||||||
//$mailer->SMTPSecure = "tls";
|
|
||||||
$mailer->Timeout = 1000;
|
$mailer->Timeout = 1000;
|
||||||
|
|
||||||
if ($mailer->smtpConnect()) {
|
if ($mailer->smtpConnect()) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ class MailTemplate extends DataStore {
|
||||||
|
|
||||||
$bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array(
|
$bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array(
|
||||||
':type' => $type,
|
':type' => $type,
|
||||||
':language' => $globalLanguage->value
|
':language' => $globalLanguage
|
||||||
));
|
));
|
||||||
|
|
||||||
return ($bean) ? new MailTemplate($bean) : null;
|
return ($bean) ? new MailTemplate($bean) : null;
|
||||||
|
|
|
@ -4,7 +4,9 @@ class Setting extends DataStore {
|
||||||
const TABLE = 'setting';
|
const TABLE = 'setting';
|
||||||
|
|
||||||
public static function getSetting($name) {
|
public static function getSetting($name) {
|
||||||
return parent::getDataStore($name, 'name');
|
$dataStore = parent::getDataStore($name, 'name');
|
||||||
|
|
||||||
|
return ($dataStore !== null) ? $dataStore->value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProps() {
|
public static function getProps() {
|
||||||
|
|
Loading…
Reference in New Issue