Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel ICS file corrupted on Office 365 #1780

Closed
bashirmurtaza93 opened this issue Jul 15, 2019 · 6 comments
Closed

Cancel ICS file corrupted on Office 365 #1780

bashirmurtaza93 opened this issue Jul 15, 2019 · 6 comments

Comments

@bashirmurtaza93
Copy link

bashirmurtaza93 commented Jul 15, 2019

There seems to be a recent issue with Office 365 when sending out cancellation Ical emails.
The main issue is that within the core code, when Ical is set, it's setting the method header to REQUEST. However, if you're sending a cancellation, you would need to set the method to CANCEL instead.

Is there anyway within PHPMailer to set this?

To be clear i'm referring to this snippet

   case 'alt':
   $body .= $mimepre;
   $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
   $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
   $body .= $this->LE . $this->LE;
   $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding);
   $body .= $this->encodeString($this->Body, $bodyEncoding);
   $body .= $this->LE . $this->LE;
   if (!empty($this->Ical)) {
      $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST, ''); //NEED TO CHANGE THIS TO CANCEL
      $body .= $this->encodeString($this->Ical, $this->Encoding);
      $body .= $this->LE . $this->LE;
      
     }
    $body .= $this->endBoundary($this->boundary[1]);
    break;
@Synchro
Copy link
Member

Synchro commented Jul 16, 2019

Not at the moment, no. I guess the best way to handle this would be to inspect the contents of the Ical property and figure out what method it should be using. Ical is generally very difficult to support because pretty much every client does not conform with RFCs (for example, Outlook should not be relying on this header at all - the status value is visible inside the Ical data), and their inconsistency makes it mostly impossible to create an ical email that works everywhere.

@bashirmurtaza93
Copy link
Author

Thanks for the quick response! I'll investigate further, and if I come up with a workaround to solve this issue, i'll post it here. Thanks!

@GeorgeWells
Copy link

I hit this problem and found a way to get it working. Use addStringAttachment to attach the ical and specify the method in 4th parameter i.e.

$mail->addStringAttachment($ical, 'ical.ics', 'base64', 'text/calendar; method=CANCEL');

@Synchro
Copy link
Member

Synchro commented Jul 19, 2019

Nice idea, @GeorgeWells. That will work for some clients but not all - there seems to be a fairly even split between those clients that want ICS files as attachments vs those that expect it as part of a multipart/alternative structure. It seems to be impossible to make it work everywhere. See #175 for more discussion on this.

@puhr-mde
Copy link
Contributor

We came up with the same Bug. The reasen is the static header 'content-type' for multipart in function createBody(). In cases of 'alt' and 'alt_attach' with !empty($this->Ical) the method will always been set to 'REQUEST'. By setting the method to canel hardcoded in my testcase, the cancellation was successfull. Needed BugFix would be a parameter oder kind of magic to set the method correctly.

if (!empty($this->Ical)) { $body .= $this->getBoundary($this->boundary[2], '', 'text/calendar; method=REQUEST', ''); $body .= $this->encodeString($this->Ical, $this->Encoding); }

Synchro pushed a commit that referenced this issue Sep 26, 2019
* Cancel ICS file corrupted on Office 365 #1780
@Synchro
Copy link
Member

Synchro commented Sep 26, 2019

Closed via #1842

@Synchro Synchro closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants