sendgrid / sendgrid-php

The Official Twilio SendGrid PHP API Library
https://sendgrid.com
MIT License
1.49k stars 623 forks source link

Custom Header for Attachments #250

Closed jfade closed 6 years ago

jfade commented 8 years ago

I'm having an issue with needing to add custom headers for attachments to an email. I'm generating and attaching calendar appointments (meeting requests) and sending them to the users of my web application. It works perfectly for Gmail users. However, for those who are using Outlook, it does not behave as expected. After some research (and finding a related issue on the nodejs Sendgrid library) it appears that Outlook expects something additional in the header with the attachment. This is the header generated by Outlook for a meeting invite:

Content-Type: text/calendar; charset="utf-8"; method=REQUEST

and this is what I can get from SendGrid:

Content-Type: text/calendar; charset=utf-8; name="1187.ics"

It appears that, in order for me to get it to behave properly, I have to add method=REQUEST to the Content-Type header on the attachment alone. (Having the attachment name does not seem like it's going to be an issue.)

I'm currently using the v2 library. The nodejs ticket referenced above says this isn't going to be an issue with v3, but after looking at the (just published) v3 for php, I don't see the ability to change the header beyond setting the content type. Is this something that can be added or am I just missing the fact that this is doable in some other way? Thanks!

NothingSethual commented 7 years ago

+1. This is really holding us back at the moment. Loving sendgrid, but this is a major kink. Would be a shame to have to switch providers over something like this. Please implement!

dimitrisnl commented 7 years ago

+1 Need this too.

litofunes commented 7 years ago

I need it too, thanks!

thinkingserious commented 7 years ago

Thanks for the votes @NothingSethual, @DimitrisNL and @litofunes!

mbernier commented 7 years ago

@jlanglais, thank you for the call. If you would like, please go to https://dx.sendgrid.com/swag and we will send you a t-shirt for your time!

mbernier commented 7 years ago

Hey @here, I just want you to know that I have been talking with the engineering team who owns this part of the code. We are working on getting this change made. It won't be deployed this quarter because it is our customer's busiest time of the year (Holiday shopping). I am actively working to get this done and I apologize that it is not done yet - as this was one of the main reasons for allowing custom content-types on the v3/mail/send API endpoint!

Please let me know if you have other feedback about anything SendGrid, our API, or our libraries. As the Developer Experience Product Manager, it is my job to be talking to customers about what we do and finding ways to make their experience better. I want to understand what you're doing with our API, how you're doing it, what you liked, what you don't like, and what would make your job easier. So, if you want to chat - please feel free to grab a time on my calendar - https://calendly.com/matt-bernier/30min

ledjon commented 6 years ago

+1 vote for this.

thinkingserious commented 6 years ago

Thanks for the vote @ledjon!

ocowchun commented 6 years ago

+1 vote for this

ataraxido commented 6 years ago

Could we have an update on this issue ?

flchaux commented 6 years ago

Yes it would be very appreciated !

Productmind commented 6 years ago

@mbernier Any update on your end? We're making our decision currently on transitioning our transactional email service and would prefer to remain with SendGrid but this has been major roadblock for our customers needs.

thinkingserious commented 6 years ago

Hi @Productmind,

I've put in a query and I'll update you when I learn more. Thanks!

NothingSethual commented 6 years ago

@thinkingserious any update here? We're in the process of transitioning away from Sendgrid if we can't sort out how to attach ICS emails. Unfortunately, it's becoming crucial to our business needs, despite loving sendgrid.

robinlambert commented 6 years ago

Same thing here!

thinkingserious commented 6 years ago

Thanks for adding your voice to the issue @NothingSethual and @robinlambert! I've passed along your feedback to our product team.

With Best Regards,

Elmer

amrsawy commented 6 years ago

I can see this thread going on for more than a year with no clear timeline for fixing the issue! So what's the point of voting?

ledjon commented 6 years ago

@amrsawy I agree. Our organization switched to Amazon's SES because of this problem. It has it's own restrictions and trade-offs but this worked correctly and was critical to our business needs.

thinkingserious commented 6 years ago

Thanks for the votes @amrsawy and @ledjon!

I'm working to get this issue visibility and implementation internally. Each time I get a new vote or comment, that allows me to increase that visibility and hopefully push it up our priority queue.

sugoireed commented 6 years ago

Need this feature too but it seems I've hit the same roadblock.

Has this not yet been resolved?

thinkingserious commented 6 years ago

Hello @sugoireed,

No, this feature is not get been implemented; however, your vote has been added. Thanks!

baynera commented 6 years ago

Please resolve this.

thinkingserious commented 6 years ago

Thanks for the vote @baynera.

tedterrill commented 6 years ago

I need this, too.

abhilashabhatia commented 6 years ago

Please resolve this for NodeJS

thinkingserious commented 6 years ago

Thanks for the votes @tedterrill and @abhilashabhatia!

NothingSethual commented 6 years ago

@thinkingserious, how many votes do we need to get some action on this? Know you guys are busy but dang, it's been two years!

thinkingserious commented 6 years ago

Hi @NothingSethual,

Unfortunately, I don't have a concrete answer to that. But, I can say that each vote helps and I will use your comment as one more means to help get this prioritized.

With Best Regards,

Elmer

brianmuse commented 6 years ago

We also need this. Really unfortunate that it's not possible at the moment. Some sort of timeline would be great. Seems like low hanging fruit to allow the necessary additional characters.

thinkingserious commented 6 years ago

Hello @brianmuse,

Thanks for adding your voice to this thread. As soon as I get any kind of timeline internally, I will post it here.

With Best Regards,

Elmer

thinkingserious commented 6 years ago

Hello Everyone!

I'm SUPER EXCITED to announce that this issue has been resolved and the fix is live in production! Please give it a try and let me know if you run into any further issue.

Thank you for your patience on this one!

With Best Regards,

Elmer

ataraxido commented 6 years ago

Hello @thinkingserious

I just tried and I still get an error ( using the API ) :

{"errors":[{"message":"The attachment type cannot contain ';', or CRLF characters.","field":"attachments.0.type","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.type"},{"message":"The attachment type cannot contain ';', or CRLF characters.","field":"attachments.1.type","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.type"}]}

Here is what I am doing using the API API :

$attachment->setType('text/calendar; charset="UTF-8"; method=REQUEST');

Are you sure the issue is solved ? What should we do ?

Thanks

Productmind commented 6 years ago

Hi Elmer,

Do you know if there’s a GitHub request open for conditional formatting support in SendGrid emails?

All the best, Michael

From: Elmer Thomas notifications@github.com Reply-To: sendgrid/sendgrid-php reply@reply.github.com Date: Monday, June 11, 2018 at 5:05 PM To: sendgrid/sendgrid-php sendgrid-php@noreply.github.com Cc: Michael Buckley michael@eventsthatflow.com, Mention mention@noreply.github.com Subject: Re: [sendgrid/sendgrid-php] Custom Header for Attachments (#250)

Hello Everyone!

I'm SUPER EXCITED to announce that this issue has been resolved and the fix is live in production! Please give it a try and let me know if you run into any further issue.

Thank you for your patience on this one!

With Best Regards,

Elmer

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/sendgrid/sendgrid-php/issues/250#issuecomment-396423972, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AZgmokiP_FSr03omnOJ0nI--zhx9eANOks5t7wWngaJpZM4I2iFB.

thinkingserious commented 6 years ago

@ataraxido,

Could you please try? $attachment->setType('text/calendar; method=REQUEST');

Thanks!

stanfea commented 6 years ago

I'm still getting this error on v3 api, I thought this was fixed already?

FAILED java.io.IOException: Request returned status Code 400Body:{"errors":[{"message":"The content type cannot contain ';', or CRLF characters.","field":"content.1.type","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content.type"}]}

thinkingserious commented 6 years ago

Hi @stefanbacon,

We added this functionality for attachment headers.

What is the end result you are looking for?

With Best Regards,

Elmer

shdnx commented 6 years ago

@thinkingserious I'm having the same problem as the ones before; the SendGrid Mail v3 API rejects attachments with type containing ';':

Failed to send e-mail! JSON: {"errors":[{"message":"The attachment type cannot contain ';', or CRLF characters.","field":"attachments.0.type","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.type"}]}

I was trying to send an iCalendar (.ics) file with type set to "text/calendar; charset=\"UTF-8\"; method=REQUEST" as mentioned earlier in this thread.

Edit: apparently this specific issue is being discussed in this thread: https://github.com/sendgrid/sendgrid-nodejs/issues/217. To summarise: setting the attachment type to "text/calendar; method=REQUEST" (without the charset) works, however, the iCalendar file is not appearing in Outlook as a calendar invite.

vanta commented 6 years ago

To summarise: setting the attachment type to "text/calendar; method=REQUEST" (without the charset) works, however, the iCalendar file is not appearing in Outlook as a calendar invite.

It works for me with Outlook 16.17 on Mac.

psociety commented 4 years ago

I was also able to send calendar events and get them parsed by gmail with:

$mail->addAttachment(
                    new \SendGrid\Mail\Attachment(
                        base64_encode('ICS_CONTENT_HERE'),
                        "text/calendar; method=REQUEST",
                        "invite.ics",
                        "attachment",
                        "attachment"
                    )
                );