Problems getting PHPmailer working

This is really weird! My email activation has been working fine and it only stops working when I add some comments section at the bottom of my php code… I did write comments in between /* */ and it gave something bout unwanted comments error…

I can’t help you if you don’t post some actual code.

I think it could be my mailer function… I am trying to get my phpmailer to work. do I need to open a separate file for php mailer or should I include it in my emailactivation file?

This is my code that I have so far…


<?php


if (!isset($_GET['email']) || !isset($_GET['activatetoken'])) {
   header("Location: ../index.php?activate=missinglink");
   exit();
} else {

  include_once 'dbh.php';
  include_once  'phpmailer/PHPMailerAutoload.php';
  

  // retrieve the email and token from url
  $activate = 0;
  $email =  $_GET['email'];
  $token =  $_GET['activatetoken'];

$sql = "SELECT * FROM users WHERE user_email = ? AND user_token = ? AND user_activate = ?";

 $stmt = mysqli_stmt_init($conn);
        //Prepare the prepared stement

        if (!mysqli_stmt_prepare($stmt, $sql)) {
            echo "SQL statement failed";

            } else {
             //Bind parameters to the placeholder
             mysqli_stmt_bind_param($stmt, "ssi", $email, $token, $activate);
             mysqli_stmt_execute($stmt);

             $result = mysqli_stmt_get_result($stmt);
             $resultCheck = mysqli_num_rows($result);
             if ($resultCheck > 0) {
           
 $activate = 1;
 $token = 'None';

$sql = "UPDATE users
        SET user_activate = ?, user_token = ?
        WHERE user_email = ?
       ";

 $stmt = mysqli_stmt_init($conn);
        //Prepare the prepared stement

        if (!mysqli_stmt_prepare($stmt, $sql)) {
            echo "SQL statement failed";

            } else {
             //Bind parameters to the placeholder
             mysqli_stmt_bind_param($stmt, "iss", $activate, $token, $email);
             mysqli_stmt_execute($stmt);

             
            $mail = new PHPmailer();
            $mail->Host = "smtp.hotail.com";
            $mail->isSMTP();
            $mail->SMTPAuth = true;
            $mail->Username = "piano0011@hotmail.com";
            $mail->Password = "*******";
            $mail->SMTPSecure = "ssl";
            $mail->Port = 465;
            $mail->Subject = "Test email";
            $mail->Body = "This is the body of the mail";
            $mail->setFrom("pianocourse101@hotmail.com", "Network Administrator");
            $mail->addAddress($email);

            if ($mail->send()) {
               echo 'mail is sent';
            } else {
               echo 'error sending mail';
            }



             
       }


  }
  
   

  }
}

I have the following files in my phpmailer directory…

I am receiving the following errors:

Warning: include_once(phpmailer/PHPMailerAutoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\loginsystem\includes\activate.php on line 10

Warning: include_once(): Failed opening 'phpmailer/PHPMailerAutoload.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\loginsystem\includes\activate.php on line 10

I don’t see PHPMailerAutoload.php in there…

Please check which path your script is in and which path phpmailer is in.

If needed, write them both out fully below each other. I’m sure you’ll see what the error is when you do that.

True, that too.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.