BUGFIX Fixed potential PHP notices if headers array not set for Bcc and Cc

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73651 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-03-25 21:43:01 +00:00
parent 0085a1ad9d
commit bd9778067c

View File

@ -399,18 +399,24 @@ class Email extends ViewableData {
if($this->bcc) $subject .= ", bcc to $this->bcc";
$subject .= ']';
} else {
if($this->cc) $headers["Cc"] = $this->cc;
if($this->bcc) $headers["Bcc"] = $this->bcc;
if($this->cc) $headers['Cc'] = $this->cc;
if($this->bcc) $headers['Bcc'] = $this->bcc;
}
if(self::$cc_all_emails_to) {
if(trim($headers['Cc'])) $headers['Cc'] .= ', ';
$headers['Cc'] .= self::$cc_all_emails_to;
if(!empty($headers['Cc']) && trim($headers['Cc'])) {
$headers['Cc'] .= ', ' . self::$cc_all_emails_to;
} else {
$headers['Cc'] = self::$cc_all_emails_to;
}
}
if(self::$bcc_all_emails_to) {
if(trim($headers['Bcc'])) $headers['Bcc'] .= ', ';
$headers['Bcc'] .= self::$bcc_all_emails_to;
if(!empty($headers['Bcc']) && trim($headers['Bcc'])) {
$headers['Bcc'] .= ', ' . self::$bcc_all_emails_to;
} else {
$headers['Bcc'] = self::$bcc_all_emails_to;
}
}
Requirements::restore();
@ -456,8 +462,8 @@ class Email extends ViewableData {
unset($headers['Cc']);
unset($headers['Bcc']);
} else {
if($this->cc) $headers["Cc"] = $this->cc;
if($this->bcc) $headers["Bcc"] = $this->bcc;
if($this->cc) $headers['Cc'] = $this->cc;
if($this->bcc) $headers['Bcc'] = $this->bcc;
}
if(self::$cc_all_emails_to) {
@ -475,7 +481,7 @@ class Email extends ViewableData {
$headers['Bcc'] = self::$bcc_all_emails_to;
}
}
Requirements::restore();
return self::mailer()->sendHTML($to, $this->from, $subject, $this->body, $this->attachments, $headers, $this->plaintext_body);