When sending mail from a script or website on a default cPanel server, you must use a proper authenticated SMTP connection. It is possible to configure your server so that SMTP authentication is not required, but this would allow for spam to be sent from your server more easily if your script or website were ever compromised. Using a proper authenticated SMTP connection for your scripts is highly recommended. This guide goes over the basics of preparing this on your cPanel account so that you can enter the required connection details into your PHP-based website or other type of script. One example of a popular PHP-based website that this is compatible with is WordPress.
NOTE: This guide does not explain the process of writing the code required to send messages via SMTP. This guide only explains the steps required to setup the connection details that you would enter into your existing website or script to use SMTP with. The following guide explains one method that your developer could use to implement the code required to send messages via SMTP on a PHP based website:
First, you must create a valid email account that your script will use to send mail from.
The following guide explains this process:
Once you have created the email account, you'll need to make sure that the password works by logging into webmail. If your domain is pointed to your cpanel server you can typically use the webmail subdomain on your domain to log in:
Once you have verified that the password works, you'll need to find a valid hostname to use as the SMTP host. Typically if your domain is pointed to your cPanel server and it has a valid SSL certificate you can just use your domain as the SMTP host.
If your domain is not pointed to your cPanel server, or if it does not have a valid SSL certificate, you can use the hostname of the server in most cases because it should always be pointed to the server and have a valid SSL certificate.
In some cases, your script may not require the SMTP host to have a valid SSL certificate. While it is not recommended to configure your script to skip SSL checking, it would be possible to use the raw IP address of the server, or a domain without an SSL certificate as the SMTP host.
The next part is to determine the port you should use. In most cases you can use either port 587 or 25.
With all of that in place you should have the following list of values that encompass everything that is required to use an authenticated SMTP connection:
- Full Email Address - Use this as the username in your website or script
- Working Password for the email account - Use this as the password
- Either your domain or the hostname of the server - Use this as the SMTP host
- Port - Again this is usually either 587 or 25
Plug those details into your website or script and you'll be all set.