-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
7.2
Description
Hello,
Symfony Mailer DataPart has supported setContentId()
since #46962
I don't believe the Postmark mailer bridge is correctly supporting this. The cid:
header is hard-coded to the attachment filename.
https://github.com/symfony/postmark-mailer/blob/3a43a9dee2f474ebf7c0328d3cd55d8c17b5df6f/Transport/PostmarkApiTransport.php#L169
Sorry I don't often report issues on Github so please let me know if there's any more information I can provide that would help.
How to reproduce
MAILER_DSN=postmark://ID@default
$sm = new Email();
$sm -> from('company@test.com');
$sm -> subject('Your Order');
$part = new DataPart(fopen('/path/to/images/logo.png', 'r'), 'test.png','image/png`);
$part -> setContentId('MyCustomCidString@my.app');
$sm -> addPart($part -> asInline());
$sm -> html('<img src="cid:MyCustomCidString@my.app" />');
$sm -> addTo('customer@test.com');
$Mailer -> send($sm);
Possible Solution
Suggest ->getContentId()
however I don't have a huge amount of experience with Symfony Mailer's code so there may be a better solution
if ('inline' === $disposition) {
$att['ContentID'] = 'cid:'.$attachment->getContentId();
}
Additional Context
Postmark API payload
["Attachments"]=>
array(1) {
[0]=>
array(4) {
["Name"]=>
string(59) "test.png"
["Content"]=>
string(2438) "xxxxxxxx"
["ContentType"]=>
string(9) "image/png"
["ContentID"]=>
string(63) "cid:test.png"
}
}
Expected API payload
["Attachments"]=>
array(1) {
[0]=>
array(4) {
["Name"]=>
string(59) "test.png"
["Content"]=>
string(2438) "xxxxxxxx"
["ContentType"]=>
string(9) "image/png"
["ContentID"]=>
string(63) "cid:MyCustomCidString@my.app"
}
}