A lot of VPS’s do not have mail functionality right out of the box, so if you install a stack like LAMP or maybe a WordPress install script (like you find on Linode or Digital Ocean) , and then try to send mail via your website, you will most likely get an error.
For example if your using Contact Form 7 in WordPress you will get “Failed to send your message”, not a very meaningful error. So the first step is to troubleshoot the problem, login via SSH and type:
This should show your servers open ports, there should be a mail program in there with a mail port open to 25 and/or port 465 (or 587) for SSL. If not then you will not be able to send any mail via PHP, unless you have configured a different port or remote service, all of which can be verified.
You can further test PHP’s mail by sending a test email using PHP’s command line or putting the following into a PHP file.
mail ( 'email@example.com', "Test mail", "Test mail from your server name" );