0

UPDATE: I've managed to find solutions for questions, asked earlier. Everything seems to work, no mistakes are shown, but I don't receive the emails

Port 465 is open and I am able to telnet it. From the advices that I've found on stackoverflow I tried to check SMTP server logging, but after installing IIS in order to enable logging, my Apache server stopped working-> I tried to change ports, but it didn't help. I got stuck...

  <?php
   require 'PHPmailer\class.phpmailer.php';
   $mail = new PHPMailer;

      $mail->IsSMTP();                                      
      $mail->Port = 465;
      $mail->Host = 'smtp.gmail.com';  
      $mail->SMTPAuth = true;                               
      $mail->Username = 'test@gmail.com';                            
      $mail->Password = 'test';                           
      $mail->SMTPSecure = 'ssl';                             
  if (!empty($_GET)){
   $errors=array();
$email = isset($_GET['email']) ? $_GET['email'] : '';
$name = isset($_GET['name']) ? $_GET['name'] : '';
$message = isset($_GET['message']) ? $_GET['message'] : '';
if (empty($name) || empty($email) || empty($message)){
$errors[]='All fields are required!';
}else{
    if (!filter_var("$email", FILTER_VALIDATE_EMAIL)){
        $errors[]='The email is not valid!';
    }
}
if (empty($errors)){
$mail->From = $email;
$mail->FromName = $name;
$mail->IsHTML(true);                                 
$mail->Body    = $message;
$mail->Subject ="From IMDB";
$mail->IsHTML(true);                                  
$result = $mail->Send();
   if(!$result) {

       echo $mail->ErrorInfo; 
   } else {
 header('Location:contactForm.php?sent');
 exit();
 }
    }

}


    ?>

I'll attach piece of php.ini as well:

     smtp_port = 465;
     auth_username = test@gmail.com
     auth_password = test
     sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

Thanks for help

  • It displays the message that email was sent, because you don't check if any was sent. If I remember correctly `$mail->Send();` should return number of sent email, if it returns 0, you should check for errors. More about errors in phpmailer: http://stackoverflow.com/q/2386544/258674 – dev-null-dweller May 26 '13 at 10:20
  • sorry, that's the old code, I'll edit it now – user2410192 May 27 '13 at 16:12
  • First of all, with PHPMailer there is no need to set up a SMTP server in your `php.ini`. Also, when creating `$mail->From`, `$mail->FromName` and `$mail->Body`, remove the single quotes, or use double quotes. In addition, `$mail->Subject` is missing. Alt last, check your firewall for outgoing connections in port 465. – Marcelo Pascual May 27 '13 at 16:26
  • Thanks, I'll try. Firewall is off – user2410192 May 27 '13 at 16:33
  • Fixed everything and found one mistake in php.ini with port. Now everything seems to work (no mistakes), but the email is not sent.. – user2410192 May 27 '13 at 16:46

0 Answers0