Jump to content

sending mail via smtp authentication


new_member

Recommended Posts

Hi,

 

I have been using php mailer class to send mail via smtp. I am using my gmail account info

 

Here is the code:

 

                    $mail = new PHPMailer();

                    $mail->IsSMTP();
                    $mail->Mailer = "smtp";
                    $mail->SMTPDebug   =    0;  
                    $mail->Host        =    "smtp.gmail.com";
                    $mail->SMTPAuth    =    true;    
                    $mail->SMTPSecure  =    "ssl";
                    $mail->Port        =    456;
                    $mail->Username    =    'gmail id';   
                    $mail->Password    =    'my password';
                    $mail->SetFrom('email from id ', 'name');
                    $mail->Subject     =     "Email Verification";
                    $mail->Body        =     'Dear '.$_GET['Name']
                    $mail->AddAddress('[email protected]',$_GET['Name']);
                    $mail->AddReplyTo('admin mail',"Admin");
                    $mail->IsHTML(true);
                    //$mail->ErrorInfo
                    if(!$mail->Send())
                       $error_mail =  "Mailer Error: ".$mail->ErrorInfo ;
                    else
                        $error_mail =  "Message has been sent";

 

 

 

It always gives me error

 

SMTP Connect() failed

 

 

I have also enabled open ssl extension and uncommented from php.ini. Have also changed the port to 25 but it didnt work. I dont know where the actual problem is??

Link to comment
https://forums.phpfreaks.com/topic/280647-sending-mail-via-smtp-authentication/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.