Description:
We need to send e-mails directly from a PHP script.
Solution:
First, in php.ini the smtp port should be set to 25, but this is usually by default. To locate your php.ini file in the server configuration you can use in the PHP script the command:
echo php_ini_loaded_file ();
Next, make sure the sendmail package is installed on your server. For nginx use:
apt-get install sendmail
In case of missing packages like sendmail-bin, install that first:
apt-get install sendmail-bin
Now you should be able to send email directly from PHP with your own server installation:
mail($mailTo, $mailSubject, $mailMessage, $mailHeaders, $mailAttachments);
For WordPress installations, you can use wp_mail() with same parameters and functionality. There are also some plugins out there, but they don’t make sense in using unless you need extra security or such.