I just updated the Laravel version for my project from 7 to 9, which switches to using Symfony Mailer instead of SwiftMailer, under the hood. So in my emails, I'm using this method (Inline Attachments) which is specified in the documentation for embedding images. Still, all emails containing embedded images are interpreted by email clients as having attachments (meaning the attachment icon is visible, usually a paperclip). In contrast, previously, in version 7, this was not the case.
How would I fix this so the email client correctly shows the attachment icon only when I attach a separate document to the email?
The issue you are facing is most likely because Symfony Mailer includes inline images as attachments by default. To fix this, you need to add a Content-Disposition header to each inline image to indicate that it should be displayed inline rather than as an attachment.
https://symfony.com/doc/current/mailer.html#embedding-images
use Symfony\Component\Mime\Part\DataPart;
// ...
$imageData = file_get_contents('/path/to/image.png');
$imagePart = new DataPart($imageData, 'image/png', 'inline');
$imagePart->setFilename('image.png');
$imagePart->headers->set('Content-Disposition', 'inline');
$mail->addPart($imagePart);