You can use imap() functions to access to webmails where you can basically do everything such as read/compose/view attachment etc, if you know how to write.
or you search for scripts online, such as rymo where you provides the smtp and mail account then you login and you will be able to view your emails and stuff. Not sure if it provides attachment functions a not but looks decent enough for basic usage.
There isn't really a complete email script outside, except for Webmail and some other.