Probably worth your time to have a comprehensive read of the manual.
See Email here:
https://wiki.contribs.org/SME_Server:Documentation:Administration_Manual:Chapter13Your script seems to be sending via port 80 which is the http port and has little relevance to normal mail transport.
Suggest you look at the ports required for
Smtp/s 25/465/587
Pop/s 110/995
Imap/s 143/993
You may find outgoing mail direct from your server is not popular with many services and you may want to use the mail server at your ISP or other SMTP service.
However, that can also be problematic if they use say Office 365 which will require individual authentication per email account which SME can't do.
YMMV....
If you have multiple POP accounts there are contribs that will help manage that.
Anyways, read the manual and links first.