SMTP class is an option but network latency between cloud server and SMTP server will delay PHP script. If SMTP server or network would be down then PHP will hang and hole server may hang (e.g. ngnix + 16 FastCGI PHP processes - 16 emails and server is down waiting for SMTP server)
With sendmail you send email and forget.
Is there lightweight sendmail that will relay email to other SMTP server like Gmail using login/password and SSL?