diff --git a/config/global.ini.php b/config/global.ini.php index 68d960e242169f9625b5a5f4f46f0d876062a8e5..c3226d012e641f61fbca026bda4776944c1d3a5d 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -253,12 +253,13 @@ ip_address_mask_length = 1 ;trusted_proxy_addresses[] = [mail] -transport = ; smtp or empty -port = 25 -host = ; SMTP server address -type = ; SMTP Auth type. By default: NONE. For example: LOGIN -username = ; SMTP username -password = ; SMTP password +transport = ; smtp (using the configuration below) or empty (using built-in mail() function) +port = ; optional; defaults to 25 when security is none or tls; 465 for ssl +host = ; SMTP server address +type = ; SMTP Auth type. By default: NONE. For example: LOGIN +username = ; SMTP username +password = ; SMTP password +encryption = ; SMTP transport-layer encryption, either 'ssl', 'tls', or empty (i.e., none). [log] ;possible values for log: screen, database, file diff --git a/core/Mail.php b/core/Mail.php index 4dbac28cb47de3b576a81fd5a2797297399d497b..526cd083de5e448b4ab09d549fb7476d8c829d51 100644 --- a/core/Mail.php +++ b/core/Mail.php @@ -49,15 +49,17 @@ class Piwik_Mail extends Zend_Mail return; } $smtpConfig = array(); - if ( !empty($config->auth->type) - || !empty($config->auth->username) - || !empty($config->auth->password) + if ( !empty($config->type) + || !empty($config->username) + || !empty($config->password) + || !empty($config->security) ) { $smtpConfig = array( - 'auth' => $config->auth->type, - 'username' => $config->auth->username, - 'password' => $config->auth->password + 'auth' => $config->type, + 'username' => $config->username, + 'password' => $config->password, + 'ssl' => $config->security, ); } diff --git a/lang/en.php b/lang/en.php index 9e69bbe039c3d5a9fc9b1a1f24ac1c0a300a0f4d..95db361ca97b6c28107b49adcac2c2781ea91173 100644 --- a/lang/en.php +++ b/lang/en.php @@ -204,11 +204,14 @@ $translations = array( 'General_AuthenticationMethodSmtp' => 'Authentication method for SMTP', 'General_SmtpUsername' => 'SMTP username', 'General_SmtpPassword' => 'SMTP password ', + 'General_SmtpEncryption' => 'SMTP encryption', 'General_SelectYesIfYouWantToSendEmailsViaServer' => 'Select "Yes" if you want or have to send e-mail via a named server instead of the local mail function', + 'General_OptionalSmtpPort' => 'Optional. Defaults to 25 for unencrypted and TLS SMTP, and 465 for SSL SMTP.', 'General_OnlyUsedIfUserPwdIsSet' => 'Only used if a username/password is set, ask your provider if you are unsure which method to use.', - 'General_OnlyEnterIfRequired' => 'Only enter a username if your SMTP server requires it', - 'General_OnlyEnterIfRequiredPassword' => 'Only enter a password if your SMTP server requires it', + 'General_OnlyEnterIfRequired' => 'Only enter a username if your SMTP server requires it.', + 'General_OnlyEnterIfRequiredPassword' => 'Only enter a password if your SMTP server requires it.', 'General_WarningPasswordStored' => '%sWarning:%s This password will be stored in the config file visible to everybody how can access it.', + 'General_EncryptedSmtpTransport' => 'Enter the transport layer encryption required by your SMTP server.', 'General_InvalidResponse' => 'The received data is invalid.', 'General_ChooseLanguage' => 'Choose language', 'General_ChoosePeriod' => 'Choose period', diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index 9c0ae90716f15c993279da29fcea58ed16ad42bf..3535b8c790b98c0fd173e1c38dae1123b6eee940 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -64,11 +64,12 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller // Update email settings $mail = Zend_Registry::get('config')->mail; $mail->transport = (Piwik_Common::getRequestVar('mailUseSmtp') == '1') ? 'smtp' : ''; - $mail->port = Piwik_Common::getRequestVar('mailPort', 25); + $mail->port = Piwik_Common::getRequestVar('mailPort', ''); $mail->host = Piwik_Common::getRequestVar('mailHost', ''); $mail->type = Piwik_Common::getRequestVar('mailType', ''); $mail->username = Piwik_Common::getRequestVar('mailUsername', ''); $mail->password = Piwik_Common::getRequestVar('mailPassword', ''); + $mail->encryption = Piwik_Common::getRequestVar('mailEncryption', ''); Zend_Registry::get('config')->mail = $mail->toArray(); $toReturn = $response->getResponse(); @@ -77,5 +78,4 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller } echo $toReturn; } - } diff --git a/plugins/CoreAdminHome/templates/generalSettings.js b/plugins/CoreAdminHome/templates/generalSettings.js index ecce87cbdec20d193fa2152d8b908e033f880e93..d8c62b0ef1b10654a827e561ac522ddc34b81cf3 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.js +++ b/plugins/CoreAdminHome/templates/generalSettings.js @@ -24,6 +24,7 @@ function getGeneralSettingsAJAX() request += '&mailType=' + $('#mailType').val(); request += '&mailUsername=' + $('#mailUsername').val(); request += '&mailPassword=' + $('#mailPassword').val(); + request += '&mailEncryption=' + $('#mailEncryption').val(); ajaxRequest.data = request; return ajaxRequest; } @@ -60,4 +61,3 @@ $(document).ready( function() { } ) }); - diff --git a/plugins/CoreAdminHome/templates/generalSettings.tpl b/plugins/CoreAdminHome/templates/generalSettings.tpl index 181a939b2dc82d165f88fd140db4f1f986f1b9bf..1d3701df635827e5c1c1a567e8631e92cfa28503 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.tpl +++ b/plugins/CoreAdminHome/templates/generalSettings.tpl @@ -73,7 +73,8 @@ <td style='width:200px'><input type="text" id="mailHost" value="{$mail.host}"></td> </tr> <tr> - <td><label for="mailPort">{'General_SmtpPort'|translate}</label></td> + <td><label for="mailPort">{'General_SmtpPort'|translate}</label><br> + <span class="form-description">{'General_OptionalSmtpPort'|translate}</i></td> <td><input type="text" id="mailPort" value="{$mail.port}"></td> </tr> <tr> @@ -81,7 +82,7 @@ <span class="form-description">{'General_OnlyUsedIfUserPwdIsSet'|translate}</span> </td> <td> - <select id="mailType" > + <select id="mailType"> <option value="" {if $mail.type eq ''} selected="selected" {/if}></option> <option id="plain" {if $mail.type eq 'PLAIN'} selected="selected" {/if} value="PLAIN">PLAIN</option> <option id="login" {if $mail.type eq 'LOGIN'} selected="selected" {/if} value="LOGIN"> LOGIN</option> @@ -107,6 +108,17 @@ <input type="password" id="mailPassword" value = "{$mail.password}" > </td> </tr> + <tr> + <td><label for="mailEncryption">{'General_SmtpEncryption'|translate}</label><br> + <span class="form-description">{'General_EncryptedSmtpTransport'|translate}</i></td> + <td> + <select id="mailEncryption"> + <option value="" {if $mail.encryption eq ''} selected="selected" {/if}></option> + <option id="ssl" {if $mail.encryption eq 'ssl'} selected="selected" {/if} value="ssl">SSL</option> + <option id="tls" {if $mail.encryption eq 'tls'} selected="selected" {/if} value="tls">TLS</option> + </select> + </td> + </tr> </table> </div>