in reply to forwarding emails with perl??

If you don't mind a non-perl solution, maildirsmtp from the serialmail package is designed to do nearly exactly what you want.