diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php index 894fac158f6e1..a2273fc3c92ee 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Http/Api/SendgridTransport.php @@ -113,9 +113,11 @@ private function getAttachments(Email $email): array $headers = $attachment->getPreparedHeaders(); $filename = $headers->getHeaderParameter('Content-Disposition', 'filename'); $disposition = $headers->getHeaderBody('Content-Disposition'); + // Sendgrid does not accept line breaks for base64 encoded attachments + $content = 'base64' === $attachment->getEncoding() ? base64_encode($attachment->getBody()) : $attachment->bodyToString(); $att = [ - 'content' => $attachment->bodyToString(), + 'content' => $content, 'type' => $headers->get('Content-Type')->getBody(), 'filename' => $filename, 'disposition' => $disposition, diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json index 1bfb16286d55b..acf44f37db6ba 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json @@ -22,6 +22,9 @@ "require-dev": { "symfony/http-client": "^4.3" }, + "conflict": { + "symfony/mime": "<4.3.3" + }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Sendgrid\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index 6a0418531525d..76181ee2fe72e 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -146,6 +146,14 @@ public function getPreparedHeaders(): Headers return $headers; } + /** + * @internal + */ + public function getEncoding(): string + { + return $this->encoding; + } + private function getEncoder(): ContentEncoderInterface { if ('8bit' === $this->encoding) {