Skip to content
Snippets Groups Projects
Commit 1f61f312 authored by Dominik Eckelmann's avatar Dominik Eckelmann
Browse files

remove empty BCC/CC mail headers

Empty BCC/CC headers may cause errors on IIS.
parent 78f0e832
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,14 @@ class TestMailer extends Mailer {
public function prop($name){
return $this->$name;
}
public function &propRef($name) {
return $this->$name;
}
public function prepareHeaders() {
return parent::prepareHeaders();
}
}
class mailer_test extends DokuWikiTest {
......@@ -90,5 +98,14 @@ class mailer_test extends DokuWikiTest {
}
}
function test_emptyBCCorCC() {
$mail = new TestMailer();
$headers = &$mail->propRef('headers');
$headers['Bcc'] = '';
$headers['Cc'] = '';
$header = $mail->prepareHeaders();
$this->assertEquals(0, preg_match('/(^|\n)Bcc: (\n|$)/', $header), 'Bcc found in headers.');
$this->assertEquals(0, preg_match('/(^|\n)Cc: (\n|$)/', $header), 'Bcc found in headers.');
}
}
//Setup VIM: ex: et ts=4 :
......@@ -553,6 +553,7 @@ class Mailer {
* @returns string the headers
*/
protected function prepareHeaders() {
$this->removeEmptyBccOrCcHeader();
$headers = '';
foreach($this->headers as $key => $val) {
$headers .= "$key: $val".MAILHEADER_EOL;
......@@ -560,6 +561,16 @@ class Mailer {
return $headers;
}
/**
* Removes empty BCC and CC Header.
*
* Empty BCC/CC Header can cause an error with Microsoft IIS.
*/
protected function removeEmptyBccOrCcHeader() {
if (isset($this->headers['Bcc']) && empty($this->headers['Bcc'])) unset($this->headers['Bcc']);
if (isset($this->headers['Cc']) && empty($this->headers['Cc'])) unset($this->headers['Cc']);
}
/**
* return a full email with all headers
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment