From e17204026fe2564726ac94d9ab4d5b644fafaf7a Mon Sep 17 00:00:00 2001 From: Michal Kliment Date: Tue, 21 Apr 2015 10:56:42 +0200 Subject: [PATCH] Added support for encryption in e-mails. --- application/controllers/settings.php | 15 +++++++++++++++ application/helpers/email.php | 3 ++- application/i18n/cs_CZ/texts.php | 1 + application/libraries/Settings.php | 5 +++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/application/controllers/settings.php b/application/controllers/settings.php index 249567f..5d3c151 100644 --- a/application/controllers/settings.php +++ b/application/controllers/settings.php @@ -1452,6 +1452,8 @@ class Settings_Controller extends Controller */ public function email() { + require_once Kohana::find_file('vendor', 'swift/Swift/Connection/SMTP'); + // access control if (!module::e('email') || !$this->acl_check_edit('Settings_Controller', 'email_settings')) @@ -1490,6 +1492,19 @@ class Settings_Controller extends Controller ->rules('valid_numeric') ->value(Settings::get('email_port')) ->help(__('For SMTP settings only.')); + + $encryptions = array + ( + Swift_Connection_SMTP::ENC_OFF => __('Off'), + Swift_Connection_SMTP::ENC_SSL => __('SSL'), + Swift_Connection_SMTP::ENC_TLS => __('TLS'), + ); + + $this->form->dropdown('email_encryption') + ->options($encryptions) + ->label('Encryption') + ->selected(Settings::get('email_encryption')) + ->help(__('For SMTP settings only.')); $this->form->input('email_username') ->label('User name') diff --git a/application/helpers/email.php b/application/helpers/email.php index 4e1756e..b5c4baf 100644 --- a/application/helpers/email.php +++ b/application/helpers/email.php @@ -40,7 +40,8 @@ class email { $connection = new Swift_Connection_SMTP ( Settings::get('email_hostname'), - Settings::get('email_port') + Settings::get('email_port'), + Settings::get('email_encryption') ); // Do authentication, if part of the DSN diff --git a/application/i18n/cs_CZ/texts.php b/application/i18n/cs_CZ/texts.php index e38fcba..4c9b784 100644 --- a/application/i18n/cs_CZ/texts.php +++ b/application/i18n/cs_CZ/texts.php @@ -1184,6 +1184,7 @@ $lang = array 'enable' => 'Zapnout', 'enabled' => 'Zapnuto', 'enabled countries' => 'Povolené země', + 'encryption' => 'Šifrování', 'end date' => 'Koncové datum', 'end editing of registrations' => 'Ukončit upravování přihlášek', 'end membership' => 'Ukončit členství', diff --git a/application/libraries/Settings.php b/application/libraries/Settings.php index 3d2d991..e28a4db 100644 --- a/application/libraries/Settings.php +++ b/application/libraries/Settings.php @@ -11,6 +11,8 @@ * */ +require_once Kohana::find_file('vendor', 'swift/Swift/Connection/SMTP'); + /** * Settings of whole FreenetIS. * Settings are cached except passwords because of security. @@ -109,6 +111,8 @@ class Settings 'email_driver' => 'native', // default email port 'email_port' => 25, + // default email encryption + 'email_encryption' => Swift_Connection_SMTP::ENC_OFF, // default value for prefix of subject of notification // e-mails to members 'email_subject_prefix' => 'FreenetIS', @@ -302,6 +306,7 @@ class Settings */ private static function init() { + // not connected? connect! if (!self::$config_model) { -- 1.9.1