-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
iCalendar invite is not showing RSVP buttons in email clients #175
Comments
The attachment is all that the iCal/ICS format defines. In google calendar invitations their MIME structure is exactly the same in PHPMailer, but the HTML message body contains links back to google calendar that fulfil the yes/no/maybe functions. PHPMailer doesn't know anything about the system the calendar relates to, so it's up to you to provide that functionality. If individual email clients have support for ics attachment types (I've not seen mail do this, but then I've only every received invitations from gcal) then it could possibly do something with it. I've found some references (on stack overflow) to exactly what things like Outlook are looking for and I've been trying them out in a local version but I've not managed to make anything special happen. I also found an ICS validator that highlighted a few problems with the bundled ICS generator class. I've realised that there isn't a code example for using calendar events, but there is a test case that's easily adapted. |
Thanks for the response. I got things sorted out. I was missing
For my situation, I was unable to use the bundled EasyPeasyICS, but I did look at the iCal unit test to see how to set things up. And I probably used the same validators as you. The validators don't seem to catch everything though; the line endings are an example of something they missed. And as you mentioned, EasyPeasyICS doesn't seem match up with RFC 5546. As ICS support is expanded, it might be worth considering replacing EasyPeasyICS with something that implements the spec. Some other things of interest that I learned through this exercise:
|
That's some great research, thanks for the effort! I've had emails with the author of EasyPeasyICS and he's happy for me to take it over, so we're free to do whatever we want with it. PHPMailer should be defaulting to CRLF line breaks; I don't think it should allow you to switch since none of the RFCs allow it. Attaching both formats seems sensible. In my experiments I needed to alter various things in PHPMailer, in particular I needed to be able to provide a content-disposition header for the ICS part (from what I read, some clients require it to be marked as 'inline') and that required extending the getBoundary method. I'll push my changes to my own fork later, see what you think. It would be good if you could wrap up your changes in a pull request. |
As far as the line endings go, the issue is with the ICS metadata. Since EasyPeasyICS is just wrapping a long string in I didn't do any patching of PHPMailer or EasyPeasyICS -- I only made modifications in my own code that was building the ICS content to avoid changing a third-party library -- but I can certainly whip up a PR to address some of the things I learned. Is the plan to put EasyPeasyICS in its own repo and make it a dependency or to just start changing it from within the PHPMailer repo? I read some of your comments about using dependency injection for the SMTP class to allow for custom implementations, so this could be another example of the same concern. I did attempt a patch of PHPMailer for adding both the attachment and the ICS message part. However, I never got it to work in Gmail and I had to give up for the time being. So it would be premature for me to try to open a PR for that. But I'll share the patch I have, as well as the email sources from PHPMailer and Gmail that I've been diff-ing to help me chase down the root cause. Maybe one of us, or someone else in the community, will be able to figure it out from there. |
Hello, i've a problem sending ical through PHPMailer to a gmail account, the ical file is send as an attachment, and for some reazon gmail don't add it to the calendar, if the same file is sent to an account and opened with Outlook, there is no problem at all. Here is an example of the ical file created with icalcreator:
Many thanks for any help you could bringme. |
If you read the rest of this thread, you'll see the problem is that the ICS file needs to be added both as an attachment and as a member of a multipart/alternative MIME structure to satisfy both gmail and outlook. The problem in PHPMailer is that we're heading for an exponential explosion in the number of possible combinations of MIME structures, and because PHPMailer only has preset options, it's getting out of hand. |
Is there an example of how to actually send an invite using phpmailer? I'm guessing on the format and order of things $invite = new EasyPeasyICS();
$invite->addEvent('06-06-2014 08:00:00','06-06-2014 17:00:00',"TEST","TEST","");
$mail = new PHPMailer();
$mail->isSMTP();
$mail->IsHTML(false);
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'spo.test.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->setFrom('david.g.obrien@test.com', 'OBrien, David');
$mail->addAddress('david.g.obrien@test.com', 'OBrien, David');
$mail->Subject = "TEST CALENDAR";
$mail->Body = $invite;
$mail->AltBody = "TEST CALENDAR";
$mail->Ical = $invite;
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
} ... |
PHPMailer expects a string containing the ICS data, so set it like this when using EasyPeasyICS: $mail->Ical = $invite->render(); |
Hello, I have the same problem than Bladezal , the RSVP buttons don't appear for me on Gmail however I include the ical in the multipart/alternative and as a attachment as you say and it works only on Outlook. I would appreciate if you could help me with this, here my headers and the Ical: Content-Type: multipart/mixed; Content-Type: multipart/alternative; --b2_48fb71c31b1b47230328819926821af0 Content-Type: text/calendar; method=REQUEST; charset=UTF-8 --b2_48fb71c31b1b47230328819926821af0 Content-Type: text/html; charset=us-ascii Host: smtp.gmail.com Attachments:
--b2_48fb71c31b1b47230328819926821af0-- --b1_48fb71c31b1b47230328819926821af0 Content-Type: text/calendar; name="invite.ics" --b1_48fb71c31b1b47230328819926821af0-- |
If you read back through this thread, you'll see that gmail is broken, and that fixing this in PHPMailer is not in the least bit simple, so it's not going to be fixed soon. |
Hi! Hopefully someone is still following this topic because I really need help with this RSVP button issue. The thing is that I don't want those buttons to to appear so that the event is automatically accepted (mainly in Outlook). Any ideas how to do that? |
If you don't want to give them a choice, why even ask? Just add them to the event without asking. |
But how do I do that? What changes do I have to make? Thanks a lot! |
I've no idea - you'd need to talk to the calendar server directly, not via email. |
For me problem was that RSVP buttons not appear in Gmail although I send valid .ics file. The solution was add proper mime type to email .ics file attachement:
I do it in laravel 5 in this way:
where $icalendar was string with content of my invite.ics file. |
You can specify a MIME type when you add an attachment:
If you don't provide a MIME type manually like this, PHPMailer has a built-in list of MIME types that it associates with file extensions automatically, however Note that when you use PHPMailer's built-in embedded iCal support (via the |
If I add an Ical and attach a file at the same time, the Ical info is not sent with the mail. If I remove the attachment, the mail is sent with the Ical info (however not recognized by Outlook/Mail..). My PHP
Gives me the following mail:
However - removing the attached file generates this:
What is causing this and why is it not working? Seemingly my ics file is valid and according to what i see in this thread.. |
Thanks for the clear description. This is down to PHPMailer's preset MIME structures - as soon as you add attachments, the message is built using the |
Thank you, that worked. They both are included now. However - I still get no RSVP buttons in either of Mac Mail and Outlook. Any idea on what is wrong? Im able to click the attached file in Mail and get it to add it to my calendar, but the same can not be done i Outlook.
|
If you do just one or the other, do the buttons you're expecting appear in either? Do you have an example message that does work correctly that we could compare it with? |
Im comparing to the reply above that @adsega posted, saying he could get it to work in Outlook. Buttons don't appear with just one or the other. |
Thank you for your continued efforts. Unfortunately it still does not work. The mail source is the following, but still no RSVP/ability to add to calendar in outlook nor Mail.
|
Does anyone have known-working examples for all the places that we want this to work that they could share? I'm working pretty much blind here. |
I happened to get sent an invitation from Apple's iCal service on iCloud. The email structure looks like this:
This message does nothing special in Mail on either macOS or iOS. There are buttons displayed, but they are just HTML from the HTML part, and the iCal part is shown as an attachment. Note that the |
@gunkire The PHPMailer code is already doing the same as what's in that example. |
I've finally solved this outside of PHPMailer, using PHP's own mail function. The issue seems to have been that the VCALENDAR object needed to have a timezone specified - this gave me the RSVP buttons.
Hope this helps you solve the issue in PHPMailer. |
... is there any solution with PhpMailer 5.2? Maybe in the new version of PhpMailer? |
You can try to set those headers for PHPMAILER : |
Look at the code; if you use PHPMailer’s iCal support, it adds exactly that header already. |
I think I've cracked it. Tested on Gmail and on Outlook. Both result in properly formatted calendar invites with RSVP buttons. I don't know exactly why it works and other solutions don't, I just know that it does! I kept trying things from StackOverflow answers and suggestions in this thread and elsewhere until I got something that worked. The VCALENDAR object looks like this:
The code that produced it looks like this:
|
I'm actually concerned in regards to @omocinteractive answer, because I cannot seem to get Outlook to recognize the DESCRIPTION field, and it looks like the image @omocinteractive posted also isn't showing the description (Which I assume should show up right below the location line) Anyone else having issues with Outlook calendar not showing the DESCRIPTION value? |
We know that Outlook is a horrible buggy mess, but you'll get better responses about it from MS support forums rather than here. |
@jdudley1123 can you share how did u make RSVP button show up on outlook ? I tried the code u share and it doesnt execute. Im using classic php with files imported into the code. Will try with composer as well. Thanks in advance |
@rohantapiyawala The code above won't execute, you'll need to do all the normal PHPMailer things first (see the tutorial). Once you've got a functional |
@jdudley1123 : Thanks for ur input and the code previously shared. I was able to solve the issue with both Google Cal and Outlook. Now my code produces RSVP button for both of them. Part I was missing was "Ical" parameter. Now I can even edit and delete my events using the ics file and PHPMailer. Cheers! |
@rohantapiyawala @jdudley1123 Can you please share what you did to have RSVP buttons on outlook? |
If you can mail me your code I can help. Sharing a working code that I use to schedule meetings for my various committees:
|
@rohantapiyawala My sample code is as mentioned above. I need to add the calendar event in Outlook, but currently its coming as ICS file attachment. What can be done here. Pls help. Thanks |
I'm using PHPMailer to send email. My ics content is:
For some reason I don't see the expected RSVP buttons in any email clients. Both Gmail and Mac Mail simply include the ics as a file attachment, I assume as a fallback. So there must be something wrong. I have not tried Outlook, but I don't see any reason why it would be different in a third client. The contents of an email being sent are below. Can you see anything that looks incorrect? Thank you.
P.S. Sorry about it being base64 encoded. I wanted to show a true representation of the email instead of changing it any way that may skew the results. I just use http://www.base64decode.org/ to decode the contents.
P.P.S. The base64 contents show as one string, but the email is sent with a max of 1000 characters per line. I just needed to remove some sensitive information, so I had to re-encode those parts, which removed the breaks.
The text was updated successfully, but these errors were encountered: