If you want to fetch all, you need to fetch
- The headers imap_fetchheader.
- Obtain the number of bodies the message has imap_fetchstructure.
- Each mine-headers a body has imap_fetchmime.
Each body it has imap_fetchbody.
Proceed like below -: $hang =imap_fetchheader($loginToInbox,$email); $hang .="\n".imap_body($loginToInbox, $email); And then directly use INSERT command to make its entry in DB.