Skip to content

Email's Footer or Header images (logo/icons) as attachments #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
saimoc opened this issue Apr 19, 2024 · 4 comments
Open

Email's Footer or Header images (logo/icons) as attachments #489

saimoc opened this issue Apr 19, 2024 · 4 comments
Labels
help wanted Extra attention is needed question

Comments

@saimoc
Copy link

saimoc commented Apr 19, 2024

Fetching the message from the server If mail has any images in email like logos/icons etc treated as attachments along with actual attachments how can I get only the actual attachments?

Thanks

@saimoc
Copy link
Author

saimoc commented Apr 22, 2024

After investigating the issue if there is any embedded image treated as an attachment when I get the HTMLBody just shows me this name not giving me the embedded link imap//. can you please propose to me the best solution for this how can I avoid this as an image or attachment
image

@Webklex Webklex added help wanted Extra attention is needed question labels Jan 17, 2025
@Giuliano1993
Copy link

Had to to more or less the same, personally I'm parsing the body and making a comparison between the id shown in the src, beside the cid and the attachment id, they mostly match.
There are some edge cases though and I'm working on a solution!
When I find a good one i'd be happy to make a PR to work with this situation, maybe returning two different properties, one for literal attachments and one for images inside the body?
@Webklex if you're interested in such a solution I'd love to come up with a PR as soon as I find an organic solution that handles also edge cases

@Giuliano1993
Copy link

For @saimoc and anyone else who land this issue for the same problem, the name after the cid in the src parameter for img in the mail body makes always the correct match with the Attachments content_id attribute.
Given this, you can work as you're more confortable images in the body normally worked as attachments. As said, now that i found out this I'll try to make a good PR for easily handling this part

@Webklex
Copy link
Owner

Webklex commented May 27, 2025

Hi @Giuliano1993 @saimoc ,
checkout this piece of code: https://github.com/Webklex/php-imap/blob/master/src/Support/Masks/MessageMask.php#L77-L86

In theory, you should be able to call $message->mask()->getHTMLBodyWithEmbeddedBase64Images()?

Best regards & happy coding,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question
Projects
None yet
Development

No branches or pull requests

3 participants