Hi All, Can anyone guide me a way to extract all the images that are part of the email body(not as attachment) in PHP. Please guide me if anyone has worked on this.
Regards, Justin Samuel.
Hi All, Can anyone guide me a way to extract all the images that are part of the email body(not as attachment) in PHP. Please guide me if anyone has worked on this.
Regards, Justin Samuel.
If there is image on an email, this one should be html.
So the image are define with a HTML tag like that
<img.....>
You have to look at the img HTML tag.
Parse the HTML part with DOMDocument::loadHTML
, get all <img>
elements with getElementsByTagName('img')
, check the src
attribute of each <img>
element, download the image (for example, using file_get_contents
).