PHPMailer Not working

Username

epiz_27284818
http://finoreminerals.com/
(please specify the website or account you are asking about)
I am using PHP mailer still my mail is not going it is linked with the SMTP account
PFA THE CODE FOR THE SAME

<?php
if(isset($_POST['submit'])){
    

require "PHPMailer/PHPMailerAutoload.php";

function smtpmailer($to, $from, $from_name, $subject, $body)
    {
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth = true; 

    $mail->SMTPSecure = 'ssl'; 
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;  
    $mail->Username = '[email protected]';
    $mail->Password = '';   

     //   $path = 'reseller.pdf';
    //   $mail->AddAttachment($path);

    $mail->IsHTML(true);
    $mail->From="[email protected]";
    $mail->FromName=$from_name;
    $mail->Sender=$from;
    $mail->AddReplyTo($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);
    if(!$mail->Send())
    {
        $error ="Please try Later, Error Occured while Processing...";
        echo $error; 
    }
    else 
    {
        $error = "Thanks You !! Your email is sent.";  
        echo $error;
    }
}

$to   = '[email protected]';
$from = '[email protected]';
$name = 'Inquiry ';
$subj = "New Inquiry from ".$_POST['name'];
$msg = "Cleint name-: ".$_POST['name']."<br><br> Cleint Email-: ".$_POST['email']."<br><br> Cleint msg-: ".$_POST['msg'];

$error=smtpmailer($to,$from, $name ,$subj, $msg);

}
?>

Hi,
PHP Mailer works a bit differently with GMail;
https://www.pepipost.com/tutorials/send-an-email-via-gmail-smtp-server-using-php/

3 Likes

i have done everything still not working, it works when on local host

Below $mail->IsSMTP(); please enter $mail->SMTPDebug = 2; rerun the script and share the response. Also you try to echo $error, is that defined?

here is the output

Try a few of these:

(Second answer)

3 Likes

Thanks worked for me!

1 Like

No problem, happy for helping, Remember to mark the answer as solved.!

2 Likes

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