0

From php.ini

sendmail_path = /usr/sbin/ssmtp -t

The code, which keeps hanging in the browser (I even changed this file to 777)

<?php
error_reporting(E_ALL);
try{
        mail('question@stackoverflow.com', 'test', 'test');
}Catch(Exception $ex){
        echo 'Exception: ', var_dump($ex, true);
}
echo "Done";
?>

Following works perfectly from terminal

sendmail -v question@stackoverflow.com
TO: question@stackoverflow.com
FROM: question@stackoverflow.com
SUBJECT: test

test
CTRL+D

(Sidenote: I am testing with UFW stopped)

Terence
  • 10,533
  • 1
  • 14
  • 20

2 Answers2

1

check this example for phpmailer. From here You will get example. And You can download phpmailer class from github.

check this github link link for download.

Ripa Saha
  • 2,532
  • 6
  • 27
  • 51
0

I changed the port from 465 to 587 inside /etc/ssmtp/smtp.conf and it works.

(Good enough for me)

Terence
  • 10,533
  • 1
  • 14
  • 20