Skip to content

Commit

Permalink
Added support for sending mail via SMTPS
Browse files Browse the repository at this point in the history
Feature request #773
  • Loading branch information
eSilverStrike committed Apr 6, 2017
1 parent 09a392a commit ed6f18a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
6 changes: 3 additions & 3 deletions language/english.php
Expand Up @@ -743,8 +743,8 @@
'np_ok' => 'The NetPBM library is installed',
'np_not_found' => 'The NetPBM executables were not found.',
'openssl_library' => 'OpenSSL Library',
'openssl_ok' => 'The OpenSSL library is loaded. This library is required if you wish to use the OAuth user login method with Geeklog.',
'openssl_not_found' => 'The OpenSSL library is not loaded. This is required <strong>only</strong> if you wish to use the OAuth user login method with Geeklog.',
'openssl_ok' => 'The OpenSSL library is loaded. This library is required if you wish to use with Geeklog the OAuth user login method or the SMTPS protocol for sending mail.',
'openssl_not_found' => 'The OpenSSL library is not loaded. This is required <strong>only</strong> if you wish to use the OAuth user login method or send mail via the SMTPS protocol with Geeklog.',
'off' => 'Off',
'ok' => 'OK',
'on' => 'On',
Expand Down Expand Up @@ -2518,7 +2518,7 @@
'range' => 'This field must be in a specified range',
'url' => 'This field must contains a valid URL',
'inList' => 'This field must contain a specified list',
'mail_settings_backend' => "This field must be one of 'smtp', 'sendmail', or 'mail'",
'mail_settings_backend' => "This field must be one of 'smtp', 'smtps', 'sendmail', or 'mail'",
'mail_settings_sendmail_path' => 'This field must contains a valid path to sendmail binary',
'mail_settings_host' => 'This field must contain a valid hostname',
'mail_settings_port' => 'This field must be between 0 - 65535',
Expand Down
6 changes: 3 additions & 3 deletions language/english_utf-8.php
Expand Up @@ -743,8 +743,8 @@
'np_ok' => 'The NetPBM library is installed',
'np_not_found' => 'The NetPBM executables were not found.',
'openssl_library' => 'OpenSSL Library',
'openssl_ok' => 'The OpenSSL library is loaded. This library is required if you wish to use the OAuth user login method with Geeklog.',
'openssl_not_found' => 'The OpenSSL library is not loaded. This is required <strong>only</strong> if you wish to use the OAuth user login method with Geeklog.',
'openssl_ok' => 'The OpenSSL library is loaded. This library is required if you wish to use with Geeklog the OAuth user login method or the SMTPS protocol for sending mail.',
'openssl_not_found' => 'The OpenSSL library is not loaded. This is required <strong>only</strong> if you wish to use the OAuth user login method or send mail via the SMTPS protocol with Geeklog.',
'off' => 'Off',
'ok' => 'OK',
'on' => 'On',
Expand Down Expand Up @@ -2518,7 +2518,7 @@
'range' => 'This field must be in a specified range',
'url' => 'This field must contains a valid URL',
'inList' => 'This field must contain a specified list',
'mail_settings_backend' => "This field must be one of 'smtp', 'sendmail', or 'mail'",
'mail_settings_backend' => "This field must be one of 'smtp', 'smtps', 'sendmail', or 'mail'",
'mail_settings_sendmail_path' => 'This field must contains a valid path to sendmail binary',
'mail_settings_host' => 'This field must contain a valid hostname',
'mail_settings_port' => 'This field must be between 0 - 65535',
Expand Down
2 changes: 1 addition & 1 deletion language/japanese_utf-8.php
Expand Up @@ -2517,7 +2517,7 @@
'range' => 'このフィールドは指定範囲内の数値を入力してください',
'url' => 'このフィールドは正しいフォーマットのURLを入力してください',
'inList' => 'このフィールドは特定のリストの要素を含まなければなりません',
'mail_settings_backend' => 'このフィールドは \'smtp\', \'sendmail\', or \'mail\'のどれか1つだけです',
'mail_settings_backend' => 'このフィールドは \'smtp\', \'smtps\', \'sendmail\', or \'mail\'のどれか1つだけです',
'mail_settings_sendmail_path' => 'このフィールドにはsendmail binaryへのパスを入力してください',
'mail_settings_host' => 'このフィールドには正しいホスト名を入力してください',
'mail_settings_port' => 'このフィールドには0から65535の数値を入力してください',
Expand Down
2 changes: 1 addition & 1 deletion public_html/admin/configuration_validation.php
Expand Up @@ -62,7 +62,7 @@
$_CONF_VALIDATE['Core']['site_mail'] = array('rule' => 'email');
$_CONF_VALIDATE['Core']['noreply_mail'] = array('rule' => 'email');
$_CONF_VALIDATE['Core']['mail_settings[backend]'] = array(
'rule' => array('inList', array('smtp', 'sendmail', 'mail')),
'rule' => array('inList', array('smtp', 'smtps', 'sendmail', 'mail')),
'message' => isset($LANG_VALIDATION['mail_settings_backend']) ?
$LANG_VALIDATION['mail_settings_backend'] : $LANG_VALIDATION['default']
);
Expand Down
14 changes: 7 additions & 7 deletions public_html/docs/english/config.html
Expand Up @@ -142,8 +142,8 @@ <h3><a name="site_mail">Site: Mail</a></h3>
that replying to those emails is recommended.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_backend">backend</a></td>
<td valign="top">mail</td>
<td valign="top">Used to select how to send email. Can be one of 'smtp',
'sendmail', or 'mail'.</td></tr>
<td valign="top">Used to select how to send email. Can be one of 'smtp', 'smtps',
'sendmail', or 'mail'. The smtps protocol requires the PHP extension OpenSSL to work.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_sendmail_path">sendmail_path</a></td>
<td valign="top"><span class="tt">/usr/bin/sendmail</span></td>
<td valign="top">If you chose 'sendmail' for the backend setting, this
Expand All @@ -155,24 +155,24 @@ <h3><a name="site_mail">Site: Mail</a></h3>
binary.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_host">host</a></td>
<td valign="top">smtp.example.com</td>
<td valign="top">If you chose 'smtp' for the backend setting, this is the
<td valign="top">If you chose 'smtp' or 'smtps' for the backend setting, this is the
SMTP server to use.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_port">port</a></td>
<td valign="top">25</td>
<td valign="top">If you chose 'smtp' for the backend setting, this is the
<td valign="top">If you chose 'smtp' (port 25) or 'smtps' (port 587) for the backend setting, this is the
port number to talk to on the SMTP server.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_auth">auth</a></td>
<td valign="top">0</td>
<td valign="top">If you chose 'smtp' for the backend setting, set this to
<td valign="top">If you chose 'smtp' or 'smtps' for the backend setting, set this to
<code>1</code> if your SMTP server requires authorization, and
<code>0</code> (or leave the field empty) if it doesn't.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_username">username</a></td>
<td valign="top">smtp-username</td>
<td valign="top">If you chose 'smtp' for the backend setting, this is the
<td valign="top">If you chose 'smtp' or 'smtps' for the backend setting, this is the
name of your SMTP account.</td></tr>
<tr><td valign="top"><a name="desc_mail_settings_password">password</a></td>
<td valign="top">smtp-password</td>
<td valign="top">If you chose 'smtp' for the backend setting, this is the
<td valign="top">If you chose 'smtp' or 'smtps' for the backend setting, this is the
password for your SMTP account.</td></tr>
<tr><td valign="top"><a name="desc_mail_cc_enabled">cc_enabled</a></td>
<td valign="top">True</td>
Expand Down
5 changes: 5 additions & 0 deletions public_html/docs/history
@@ -1,5 +1,10 @@
Geeklog History/Changes:

Future (2.1.2)
------------

- [Feature] Added ability to use SMTPS protocol for sending mail [Ivy] [Tom]


March 1, 2017 (2.1.2)
------------
Expand Down
10 changes: 10 additions & 0 deletions system/classes/Mail.php
Expand Up @@ -76,6 +76,16 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr
}

break;

case 'smtps':
$transport = \Swift_SmtpTransport::newInstance($_CONF['mail_settings']['host'], $_CONF['mail_settings']['port'], 'ssl');

if (!empty($_CONF['mail_settings']['auth'])) {
$transport->setUsername($_CONF['mail_settings']['username']);
$transport->setPassword($_CONF['mail_settings']['password']);
}

break;

case 'mail':
default:
Expand Down

0 comments on commit ed6f18a

Please sign in to comment.