It appears that your server requires either POP3 authentication before
sending an email or SMTP authentication during the sending process. I don't
see any authentication being done in your script. (SendEmail())
You need to login to the mail server in this routine before you will be
allowed to generate emails outside your hosted domain.
I think this is done by simply specifying a username and password to use by
the call to the SMTP server but I cannot remember.
The other option would be to allow all mail from localhost but that opens up
a can or worms (or SPAM).