I am using phpMailer to send email with PHP.
I implemented exactly the same concept in mod_perl a few years ago. Keep in mind that most of your outgoing mail is likely to be blocked if you send a significant amount. And if your system can be hacked (and it sounds at least believable), spammers can find it and use your system, which will lead to blocking all your outgoing email.
Sending e-mail is more complicated than it should be (considering technology only) thanks to spam and spam filters. These days, it's often easier for me to write code that uses a third-party service to actually send emails by submitting addresses via the API. I was lucky recently with MailChimp and Contactology APIs.
EDIT: as for an incoming letter: if you were not in a situation with shared hosting, it would not be so difficult - just grab it, split the headers and pull it back to the new address. I have to agree with Conrad, I think at this point - the shared PHP script host seems like a pretty suboptimal environment to try and solve this problem. If you cannot use system () to directly pass the mail infrastructure, I think you need to completely parse the incoming email and collect it.
source share