Look at Net::SMTP::Server, build a wrapper around your program and (for security reasons) let your local mailserver deliver the mail to your programm on a non-standard port via 127.0.0.1
For SOAP: Read the beginning of the description of SOAP::Simple, it perfectly describes SOAP.