Skip to content

[Mailer] Attachments fail with Sendgrid transport due to base64 encoding format #33671

Closed
@fyfey

Description

@fyfey

Symfony version(s) affected: 4.3

Description
When using the Sendgrid HTTP transport; Sending an email with an attachment results in an error 400 "The attachment content must be base64 encoded." Exception.

The Sendgrid API does not like line breaks in the base64 encoded attachment content it appears, but the Base64Encoder in Mime do.

How to reproduce
Create a new Symfony\Component\Mime\Email, attach some arbitrary content and send the email.

Possible Solution
In Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport::getAttachments, replace the \r\n in the content returned from $attachment->bodyToString.

I have created a PR #33672

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions