From 7c377bbcd27a60cc92f93f2e0c2d6423662b2227 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 16 Oct 2013 16:48:59 +0000 Subject: [PATCH] central mail sending --- lam/docs/manual-sources/howto.xml | 33 ++++++++++++++++-- .../manual-sources/images/configGeneral6.png | Bin 0 -> 4666 bytes lam/help/help.inc | 2 ++ lam/lib/account.inc | 19 +++++++++- lam/lib/config.inc | 8 +++-- lam/templates/config/mainmanage.php | 19 ++++++++++ 6 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 lam/docs/manual-sources/images/configGeneral6.png diff --git a/lam/docs/manual-sources/howto.xml b/lam/docs/manual-sources/howto.xml index 1473e873..526bbc40 100644 --- a/lam/docs/manual-sources/howto.xml +++ b/lam/docs/manual-sources/howto.xml @@ -1030,6 +1030,28 @@ Have fun! +
+ Additional options + + Email + format + + Some email servers are not standards compatible. If you receive + mails that look broken you can change the line endings for sent mails + here. Default is to use "\r\n". + + At the moment, this option is only available in LAM Pro as there + is no mail sending in the free version. + + + + + + + + +
+
Change master password @@ -5255,7 +5277,9 @@ Run slapindex to rebuild the index. If the user account has set the mail attribute then LAM can send your user a mail with the new password. You can change the mail template to fit your needs. Please configure your LAM server profile - to setup the sender address, subject and mail body. + to setup the sender address, subject and mail body. Please see email format option in case of broken + mails. Using this method will prevent that your support staff knows the new password. @@ -6083,7 +6107,9 @@ Run slapindex to rebuild the index. change. The mail can include the new password by using the special wildcard "@@newPassword@@". Additionally, you may want to insert other wildcards that are replaced by the corresponding LDAP - attributes. E.g. "@@uid@@" will be replaced by the user name. + attributes. E.g. "@@uid@@" will be replaced by the user name. Please + see email format option in case of + broken mails. @@ -6292,6 +6318,9 @@ Run slapindex to rebuild the index. valid for 24 hours. When he clicks on this link then the account will be created in the self service user suffix. The DN will look like this: uid=<user name>,... + + Please see email format + option in case of broken mails.
diff --git a/lam/docs/manual-sources/images/configGeneral6.png b/lam/docs/manual-sources/images/configGeneral6.png new file mode 100644 index 0000000000000000000000000000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EsJBWRq;qXvPg^c|Y|0)a&g2eeoX>U; zVELBS1hzKT1cR-_QrvJ9OasD$7FhrGlO2*J%0g!tVLY!+TBFMA{LxzT4gDR7DXYnUyvk#X+UHF}W8VX7G(`J5`m8giL zhsTzt_R+jUeW@_{K8G@bWzHR zmQ(V`x&{AD2bWx@L5`^28Pra7SAMEQ0rxwBFnB#8VX{koaP-E@? xE=zb$pZrs+cpv`1D_Q*KA@%<=aNj-yIuyuvw+;CF|4A-%9~o(uJ$&}^zW{yl|B(Oy literal 0 HcmV?d00001 diff --git a/lam/help/help.inc b/lam/help/help.inc index 8f265b99..5b6ecab6 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -149,6 +149,8 @@ $helpArray = array ( "Text" => _("This is a list of IP addresses from hosts who may access LAM. You can use \"*\" as wildcard (e.g. 192.168.0.*).")), "242" => array ("Headline" => _("Password policy"), "Text" => _("Here you can specify minimum requirements for passwords. The character classes are: lowercase, uppercase, numeric and symbols.")), + "243" => array ("Headline" => _('Email format'), + "Text" => _('Please change this setting only if you experience problems in receiving emails from LAM. This defines the line ending of emails.')), "250" => array ("Headline" => _("Filter"), "Text" => _("Here you can input simple filter expressions (e.g. 'value' or 'v*'). The filter is case-sensitive.")), "260" => array ("Headline" => _("Additional LDAP filter"), diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 1773b120..3300db14 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -989,7 +989,7 @@ function sendPasswordMail($pwd, $user, $recipient = null) { $found = preg_match('/\@\@[^\@]+\@\@/', $body, $results); } $headerLines = createEMailHeaders($mailFrom, ($mailIsHTML == 'true'), $mailReplyTo); - $success = mail($mailTo, base64EncodeForEMail($subject), $body, $headerLines); + $success = sendEMail($mailTo, $subject, $body, $headerLines); if ($success) { logNewMessage(LOG_DEBUG, 'Sent password mail to ' . $mailTo); return array( @@ -1045,6 +1045,23 @@ function base64EncodeForEMail($value) { return '=?UTF-8?B?' . base64_encode($value) . '?='; } +/** + * Sends out an email. + * + * @param String $to TO address + * @param String $subject email subject + * @param String $text mail body (with \r\n EOL) + * @param String $headers header lines (with \r\n EOL) + */ +function sendEMail($to, $subject, $text, $headers) { + if (!empty($_SESSION['cfgMain']->mailEOL) && ($_SESSION['cfgMain']->mailEOL === 'unix')) { + $text = str_replace("\r\n", "\n", $text); + $headers = str_replace("\r\n", "\n", $headers); + } + logNewMessage(LOG_WARNING, $text); + return mail($to, base64EncodeForEMail($subject), $text, $headers); +} + /** * Caches module objects. * This improves performance if the same module does not need to be created multiple times (calling get_metaData() each time). diff --git a/lam/lib/config.inc b/lam/lib/config.inc index cba2e190..287a797f 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -1396,12 +1396,15 @@ class LAMCfgMain { /** SSL certificate should be deleted on save() */ private $delSSLCaCert = false; + + /** EOL for emails (default/unix) */ + public $mailEOL = 'default'; /** list of data fields to save in config file */ private $settings = array("password", "default", "sessionTimeout", "logLevel", "logDestination", "allowedHosts", "passwordMinLength", "passwordMinUpper", "passwordMinLower", "passwordMinNumeric", - "passwordMinClasses", "passwordMinSymbol"); + "passwordMinClasses", "passwordMinSymbol", "mailEOL"); /** * Loads preferences from config file @@ -1486,6 +1489,7 @@ class LAMCfgMain { if (!in_array("passwordMinNumeric", $saved)) array_push($file_array, "\n\n# Password: minimum numeric characters\n" . "passwordMinNumeric: " . $this->passwordMinNumeric); if (!in_array("passwordMinSymbol", $saved)) array_push($file_array, "\n\n# Password: minimum symbolic characters\n" . "passwordMinSymbol: " . $this->passwordMinSymbol); if (!in_array("passwordMinClasses", $saved)) array_push($file_array, "\n\n# Password: minimum character classes (0-4)\n" . "passwordMinClasses: " . $this->passwordMinClasses); + if (!in_array("mailEOL", $saved)) array_push($file_array, "\n\n# Email format (default/unix)\n" . "mailEOL: " . $this->mailEOL); $file = @fopen($this->conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -1759,7 +1763,7 @@ class LAMCfgMain { } return $list; } - + } ?> diff --git a/lam/templates/config/mainmanage.php b/lam/templates/config/mainmanage.php index 41938e5b..f14dfe7d 100644 --- a/lam/templates/config/mainmanage.php +++ b/lam/templates/config/mainmanage.php @@ -170,6 +170,10 @@ if (isset($_POST['submitFormData'])) { $cfg->deleteSSLCaCert($index); } } + // mail EOL + if (isLAMProVersion()) { + $cfg->mailEOL = $_POST['mailEOL']; + } // save settings if (isset($_POST['submit'])) { $cfg->save(); @@ -370,6 +374,21 @@ $loggingTable->addElement(new htmlInputField('logFile', $destinationPath), true) $container->addElement($loggingTable, true); $container->addElement(new htmlSpacer(null, '10px'), true); +// additional options +if (isLAMProVersion()) { + $container->addElement(new htmlSubTitle(_('Additional options')), true); + $additionalTable = new htmlTable(); + $mailEOLOptions = array( + _('Default (\r\n)') => 'default', + _('Non-standard (\n)') => 'unix' + ); + $mailEOLSelect = new htmlTableExtendedSelect('mailEOL', $mailEOLOptions, array($cfg->mailEOL), _('Email format'), '243'); + $mailEOLSelect->setHasDescriptiveElements(true); + $additionalTable->addElement($mailEOLSelect, true); + $container->addElement($additionalTable, true); + $container->addElement(new htmlSpacer(null, '10px'), true); +} + // change master password $container->addElement(new htmlSubTitle(_("Change master password")), true); $passwordTable = new htmlTable();