Angle brackets by default in Content-ID and Message-ID headers
sunnyphp opened this issue · 1 comments
sunnyphp commented
Hello.
I would suggest using angle brackets in values of the Content-ID and Message-ID headers by default (auto addition in value).
Without angle brackets, image cannot be displayed, even if it does not contain special characters.
Example:
$logo = 'logotype.jpg';
$htmlBody = '<html><body><img src="cid:logotype"></body></html>';
$message = (new MessageBodyCollection($htmlBody))
->withEmbeddedImage(new EmbeddedImage(
new StringStream(file_get_contents($logo)),
basename($logo),
new ContentType('image/jpeg'),
new ContentID('logotype')
))
->createMessage()
->withHeader(new Subject('Привет мир'))
->withHeader(From::fromAddress('admin@mail.ru', 'Mail.ru'))
->withHeader(To::fromSingleRecipient('admin@gmail.com', 'Виталий'))
;
$transport = new PhpMailTransport(EnvelopeFactory::useExtractedHeader());
$transport->send($message);
But if we replace on that:
new ContentID('<logotype>')
It works.
Tested on CentOS (core Linux 2.6.32-042stab123.9 #1 SMP Thu Jun 29 13:01:59 MSK 2017 x86_64 GNU/Linux
), PHP 7.2.8 (NTS) and Gmail.
An example of the link example/transport-smtp.php did not check, but I can assume that it is also not working in withEmbeddedImage
method.
Thanks.
frederikbosch commented
Use ContentID::fromUrlAddress('id', 'domain.com')
. Replace domain.com with the same address as your envelope domain and pick some random id for the first argument.