How do I test PHP SMTP functionality?

You can test PHP SMTP functions with the following two examples. The first one is standard SMTP while the second one is SMTP with SSL.

We strongly recommend using an SMTP relay that requires authentication. Sending mail through unauthenticated SMTP servers (including the localhost relay on Cloud Sites) can result in delays or undelivered email due to stringent anti-spam filters.

Sending with PHP SMTP

You will only need to change the following variables:

$from

$to

$subject

$body

$host

$username

$password

The host, username, and password values will depend on the provider you're using to send your email. If you have a legacy Sites email account or are using Rackspace Email the host would be "mail.emailsrvr.com" and the username would be your email address. If you're using another service such as Mailgun or Gmail to send email, you'll need to fill in the SMTP server for that service. Mailgun server information can be accessed via your Mailgun control panel.

Note: Mail.php is a PEAR module and is installed on the server. It is included in the default include_path for PHP, so requiring it here will work by default without any additional effort on your part.