0

I know there are so many similar Questions like this but mine is diffent so plz be kind and help me out.

<?php
require 'includes/PHPMailer.php';
require 'includes/SMTP.php';
require 'includes/Exception.php';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

$mail=new PHPMailer();
$mail->isSMTP();
$mail->Host="smtp.gamil.com";
$mail->SMTP ="true";
$mail->SMTPSecure="tls";
$mail->Port="587";
$mail->Username="astaquag@gmail.com";
$mail->password="*******";
$mail->Subject="Mail from Astaqua.com";
$mail->setfrom("astaquag@gmail.com");
$mail->Body="A.J Dep is the best ";
$mail->addAddress("astaquag@gmail.com");

if ( $mail->send() ) 
{
 echo "Email Sent..!";
}
else{
    echo "Error..!";
}
$mail->smtpClose();

?>

and Error is this:

Parse error: syntax error, unexpected token "if" in C:\xampp\htdocs\phpmailer\includes\index.php on line 23

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
  • 1
    I don't see how the error is related to the code you posted. Did you copy/paste the code? That error would occur if you missed the `;` in the line _before_ your `if` – brombeer Nov 28 '21 at 13:24
  • This the exact code in my Visual Studio I posted here. As u can c I didnt miss the ; – Anjana Dep Nov 28 '21 at 13:28
  • 1
    That's why I can't see how the error is related to _this_ code. Are you certain this is the file `C:\xampp\htdocs\phpmailer\includes\index.php`? How many `includes/` folders are there in your project? – brombeer Nov 28 '21 at 13:31
  • 1
    Just to make sure; if this is the file it's complaining about and you've copy/pasted the code from your IDE, are you sure that the file is saved? That you haven't made changes in your IDE but forgot to save the changes. Because the above code can't produce that error. – M. Eriksson Nov 28 '21 at 13:40

0 Answers0