CC and BCC address for password notification jobs (RFE 134)

This commit is contained in:
Roland Gruber 2016-05-14 11:22:36 +02:00
parent 06e716139a
commit 3387e210ad
6 changed files with 70 additions and 9 deletions

View File

@ -2074,6 +2074,18 @@ mysql> GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<entry>Optional Reply-to address for email.</entry>
</row>
<row>
<entry>CC address</entry>
<entry>Optional CC mail address.</entry>
</row>
<row>
<entry>BCC address</entry>
<entry>Optional BCC mail address.</entry>
</row>
<row>
<entry>Subject</entry>
@ -2170,6 +2182,18 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<entry>Optional Reply-to address for email.</entry>
</row>
<row>
<entry>CC address</entry>
<entry>Optional CC mail address.</entry>
</row>
<row>
<entry>BCC address</entry>
<entry>Optional BCC mail address.</entry>
</row>
<row>
<entry>Subject</entry>
@ -2250,6 +2274,18 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<entry>Optional Reply-to address for email.</entry>
</row>
<row>
<entry>CC address</entry>
<entry>Optional CC mail address.</entry>
</row>
<row>
<entry>BCC address</entry>
<entry>Optional BCC mail address.</entry>
</row>
<row>
<entry>Subject</entry>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -325,6 +325,14 @@ $helpArray = array (
"Headline" => _('Notification period'),
"Text" => _('Please enter the number of days before password expiration to send out the email.')
),
'805' => array(
"Headline" => _('CC address'),
"Text" => _('This email address will be set as CC address of all mails.')
),
'806' => array(
"Headline" => _('BCC address'),
"Text" => _('This email address will be set as BCC address of all mails.')
),
);
/* This is a sample help entry. Just copy this line an modify the values between the [] brackets.

View File

@ -1093,21 +1093,23 @@ function sendPasswordMail($pwd, $user, $recipient = null) {
* @param String $from FROM address
* @param boolean $isHTML mail is formatted as HTML or plain text
* @param String $replyTo reply-to address (optional)
* @param String $cc CC address
* @param String $bcc BCC address
* @return String header lines
*/
function createEMailHeaders($from, $isHTML, $replyTo = null) {
function createEMailHeaders($from, $isHTML, $replyTo = null, $cc = null, $bcc = null) {
$headerLines = "X-Mailer: LDAP Account Manager\r\n";
if (!empty($from)) {
if (preg_match('/^(.*)<(.*)>$/', $from, $matchesFrom)) {
$from = base64EncodeForEMail($matchesFrom[1]) . ' <' . $matchesFrom[2] . '>';
}
$headerLines .= 'From: ' . $from . "\r\n";
$headerLines .= 'From: ' . encodeMailAddress($from) . "\r\n";
}
if (!empty($replyTo)) {
if (preg_match('/^(.*)<(.*)>$/', $replyTo, $matchesReplyTo)) {
$replyTo = base64EncodeForEMail($matchesReplyTo[1]) . ' <' . $matchesReplyTo[2] . '>';
}
$headerLines .= 'Reply-To: ' . $replyTo . "\r\n";
$headerLines .= 'Reply-To: ' . encodeMailAddress($replyTo) . "\r\n";
}
if (!empty($cc)) {
$headerLines .= 'Cc: ' . encodeMailAddress($cc) . "\r\n";
}
if (!empty($bcc)) {
$headerLines .= 'Bcc: ' . encodeMailAddress($bcc) . "\r\n";
}
$headerLines .= "MIME-Version: 1.0\r\n";
if ($isHTML) {
@ -1119,6 +1121,21 @@ function createEMailHeaders($from, $isHTML, $replyTo = null) {
return $headerLines;
}
/**
* Encodes the email address for the header part of an email.
*
* @param String $address email address
* @return String encoded mail address
*/
function encodeMailAddress($address) {
$matches = array();
// if the email contains a name part then base64 encode it
if (preg_match('/^(.*)<(.*)>$/', $address, $matches)) {
return base64EncodeForEMail($matches[1]) . ' <' . $matches[2] . '>';
}
return $address;
}
/**
* Returns a base64 encoded string of the given values in a fomat that is used in emails.
*