-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Closed
Copy link
Description
Symfony version(s) affected: 4.3.x / 4.4
Description
Attachments or embedded images sent with the Mandrill (MailChimp) API are currently ignored. This is because the attachments
and images
JSON keys are not set within the message
key as mentioned in the documentation and that the name
key is missing.
How to reproduce
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport;
$transport = Transport::fromDsn(sprintf('api://%s@mandrill', 'YOUR_KEY'));
$mailer = new Mailer($transport);
$email = new Email();
$email
->from('test@example.com')
->subject('Subject')
->text('Message')
->to('recipient@example.com')
->embedFromPath('path/to/file.png', 'IMAGECID')
->attachFromPath('path/to/attachment')
->html('<p>Test</p><img src="cid:IMAGECID"><p>Test 2</p>')
;
$mailer->send($email);
This will generate a payload like this:
{
"message": {
"html": "<p>Test</p><img src=\"cid:IMAGECID\"><p>Test 2</p>",
},
"attachments": [
{
"type": "text/plain",
"content": "ZXhhbXBsZSBmaWxl"
}
],
"images": [
{
"type": "image/png",
"content": "ZXhhbXBsZSBmaWxl"
}
]
}
instead of
{
"message": {
"html": "<p>Test</p><img src=\"cid:IMAGECID\"><p>Test 2</p>",
"attachments": [
{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl"
}
],
"images": [
{
"type": "image/png",
"name": "IMAGECID",
"content": "ZXhhbXBsZSBmaWxl"
}
]
}
}
Possible Solution
- Include the
name
key for each attachment or embedded image. - Place the
attachment
andimages
entries at the right place.
Additional context