0

I want to send mail with phpmailer from my host,but when i run this code,any message show in result. what is my problem in this code?

<?php
require_once("PHPMailer-master/class.phpmailer.php");
$mail = new PHPMailer();
$mail->addAddress("mehregan.programmer@gmail.com"); // recipient Email
$mail->setFrom("info@mehregan-software.ir"); // Sender Email
$mail->Subject="title";
$mail->Body="hello world !";
$mail->isSMTP();
$mail->Host="mail.mehregan-software.ir"; // SMTP Host
$mail->Username="info@mehregan-software.ir";   //I created this mail in my host
$mail->Password="*****"; // password for email
$mail->SMTPSecure="ssl";
$mail->Port=465;
$mail->SMTPAuth = true;
   if(!$mail->Send()) {
        echo 'Message was not sent.';
        echo 'Mailer error: ' . $mail->ErrorInfo;
        exit;
   } else {
        echo 'Message has been sent.';
   }
?>

here is my host and smtp information enter image description here enter image description here

TIGER
  • 2,864
  • 5
  • 35
  • 45
v4mpir3
  • 11
  • 1
  • 4
  • enable `error_reporting(E_ALL);` and let us know the error message. – TIGER Dec 04 '16 at 14:33
  • @Tiger how can i enable it? – v4mpir3 Dec 04 '16 at 14:34
  • just write this code at top of your script. `ini_set('display_errors',1); error_reporting(E_ALL);` for more details go [HERE](http://php.net/manual/en/function.error-reporting.php) – TIGER Dec 04 '16 at 14:35
  • @Tiger in chrome when i try to run it The mehregan-software.ir page isn’t working HTTP ERROR 500 and in firefox show a blank page to me – v4mpir3 Dec 04 '16 at 14:44
  • @v4mpir3, please have a look my answer here: http://stackoverflow.com/a/40793025/1960558 – Ruhul Amin Dec 04 '16 at 14:45
  • @RuhulAmin I try to enable error log but any change in my result – v4mpir3 Dec 04 '16 at 14:49
  • You should get the latest version of PHPMailer, read the docs and use the examples provided with it. I suspect it's because you're using SMTP but did not load the autoloader. – Synchro Dec 04 '16 at 15:44
  • @Synchro where can i find a latest phpmailer? how can i load autoloader? – v4mpir3 Dec 04 '16 at 15:47
  • Follow the link in the PHPMailer tag on this question. – Synchro Dec 04 '16 at 16:40

0 Answers0