mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +01:00
* Calendar Notification: handle calendar requests correctly as multipart/alternative; one part text/plain the other part text/calendar
This commit is contained in:
parent
c0692ac303
commit
3df142b00b
@ -91,18 +91,28 @@ class notifications_email implements notifications_iface {
|
||||
|
||||
$this->mail->ClearAddresses();
|
||||
$this->mail->ClearAttachments();
|
||||
$this->mail->IsHTML(true);
|
||||
$this->mail->AddAddress($this->recipient->account_email, $this->recipient->account_fullname);
|
||||
$this->mail->AddCustomHeader('X-eGroupWare-type: notification-mail');
|
||||
$this->mail->From = $this->sender->account_email;
|
||||
$this->mail->FromName = $this->sender->account_fullname;
|
||||
$this->mail->Subject = $this->mail->encode_subject($_subject);
|
||||
$this->mail->Body = $body_html;
|
||||
$this->mail->AltBody = $body_plain;
|
||||
if(is_array($_attachments) && count($_attachments) > 0) {
|
||||
foreach($_attachments as $attachment) {
|
||||
$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.array2string($_attachments));
|
||||
if ($_attachments && stripos($_attachments[0]->type,"text/calendar; method=")!==false)
|
||||
{
|
||||
$this->mail->Body = $body_plain;
|
||||
$this->mail->AltBody = $_attachments[0]->string;
|
||||
$this->mail->AltBodyContentType = $_attachments[0]->type;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->mail->IsHTML(true);
|
||||
$this->mail->Body = $body_html;
|
||||
$this->mail->AltBody = $body_plain;
|
||||
if(is_array($_attachments) && count($_attachments) > 0) {
|
||||
foreach($_attachments as $attachment) {
|
||||
$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$error=$this->mail->Send()) {
|
||||
throw new Exception("Failed sending notification message via email.$error".print_r($this->mail->ErrorInfo,true));
|
||||
|
@ -108,6 +108,12 @@ class PHPMailer {
|
||||
*/
|
||||
public $Subject = '';
|
||||
|
||||
/**
|
||||
* Sets the ContentType of the Body; default is text/plain
|
||||
* @var string
|
||||
*/
|
||||
public $BodyContentType = 'text/plain';
|
||||
|
||||
/**
|
||||
* Sets the Body of the message. This can be either an HTML or text body.
|
||||
* If HTML then run IsHTML(true).
|
||||
@ -115,6 +121,12 @@ class PHPMailer {
|
||||
*/
|
||||
public $Body = '';
|
||||
|
||||
/**
|
||||
* Sets the ContentType of the AltBody; default is text/plain
|
||||
* @var string
|
||||
*/
|
||||
public $AltBodyContentType = 'text/plain';
|
||||
|
||||
/**
|
||||
* Sets the text-only body of the message. This automatically sets the
|
||||
* email to multipart/alternative. This body can be read by mail
|
||||
@ -360,6 +372,7 @@ class PHPMailer {
|
||||
} else {
|
||||
$this->ContentType = 'text/plain';
|
||||
}
|
||||
$this->BodyContentType = $this->ContentType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1098,7 +1111,6 @@ class PHPMailer {
|
||||
switch($this->message_type) {
|
||||
case 'alt':
|
||||
case 'alt_attachments':
|
||||
case 'alt_extended':
|
||||
$this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
|
||||
break;
|
||||
default:
|
||||
@ -1204,7 +1216,6 @@ class PHPMailer {
|
||||
break;
|
||||
case 'attachments':
|
||||
case 'alt_attachments':
|
||||
case 'alt_extended':
|
||||
if($this->InlineImageExists()){
|
||||
$result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
|
||||
} else {
|
||||
@ -1241,10 +1252,10 @@ class PHPMailer {
|
||||
|
||||
switch($this->message_type) {
|
||||
case 'alt':
|
||||
$body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
|
||||
$body .= $this->GetBoundary($this->boundary[1], '', $this->AltBodyContentType, ''); // may be set by client, defaults to text/plain
|
||||
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
|
||||
$body .= $this->LE.$this->LE;
|
||||
$body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
|
||||
$body .= $this->GetBoundary($this->boundary[1], '', $this->BodyContentType, ''); //is dependent on IsHTML
|
||||
$body .= $this->EncodeString($this->Body, $this->Encoding);
|
||||
$body .= $this->LE.$this->LE;
|
||||
$body .= $this->EndBoundary($this->boundary[1]);
|
||||
@ -1270,22 +1281,6 @@ class PHPMailer {
|
||||
$body .= $this->EndBoundary($this->boundary[2]);
|
||||
$body .= $this->AttachAll();
|
||||
break;
|
||||
case 'alt_extended':
|
||||
$body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
|
||||
$body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
|
||||
$body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
|
||||
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
|
||||
$body .= $this->LE.$this->LE;
|
||||
$body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
|
||||
$body .= $this->EncodeString($this->Body, $this->Encoding);
|
||||
$body .= $this->LE.$this->LE;
|
||||
// Create the extended body for an attached text/calendar
|
||||
$body .= $this->GetBoundary($this->boundary[2], '', $this->attachment[0][4], '') . $this->LE;
|
||||
$body .= $this->EncodeString($this->attachment[0][0], $this->attachment[0][3]);
|
||||
$body .= $this->LE.$this->LE;
|
||||
$body .= $this->EndBoundary($this->boundary[2]);
|
||||
$body .= $this->AttachAll();
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->IsError()) {
|
||||
@ -1376,9 +1371,6 @@ class PHPMailer {
|
||||
if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
|
||||
$this->message_type = 'alt_attachments';
|
||||
}
|
||||
if(strlen($this->AltBody) > 0 && count($this->attachment) > 0 && stripos($this->attachment[0][4],'text/calendar')!==false) {
|
||||
$this->message_type = 'alt_extended';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user