I'm a bit stuck here. I have some websites hosted on TSOHosts. I use the php mail() function to send the occassional email, e.g. from a contact form. The emails have stopped working, and nobody at the hosting provider seems to be capable of fixing it. They say I should use SMTP emails. OK, I get that, they point me to this article on how to do it: https://www.lifewire.com/send-email-from-php-script-using-smtp-authentication-and-ssl-1171197
So I write the script (below) and, it doesnt work:
require_once "Mail.php";
$from = "NoReply@mysite.org.uk";
$to = "me@myemailaddress.co.uk";
$subject = "Hi port 465";
$body = "Hello World";
$host = "ssl://mail3.gridhost.co.uk";
$port = "465";
$username = "username@mysite.org.uk;
$password = "Testing123";
$headers = array (
'From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
echo "<p>".$mail->getMessage()."</p>";
}
else
{
echo"<p>Message successfully sent!</p>";
}
I also have a port 25, non-ssl script, that also doesnt work. When I say doesnt work, its not throwing an error, just no email arrives (checked in spam).
The hosting company first asked me where the Mail.php is as referred to by the require_once "Mail.php" line The article suggests that this should be installed on php4+ (Im using 5.6.37)
This is remarkably similar to this article: smtp configuration for php mail
But I am stummped as to how to proceed.