Hi there…
Is there any way to enable IMAP for use by PHP?
Not quite step by step, but this may help:
https://panel.dreamhost.com/kbase/index.cgi?area=2538
Also, if you explain what you’re trying to do, perhaps someone can suggest another way of doing it. I’d personally avoid PHP (especially the version running as an Apache modules) for any mail-type stuff on a shared server.