Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:30:22+00:00 2026-06-11T18:30:22+00:00

Hi I am using phpMailer For sending email. Its working fine on server, but

  • 0

Hi I am using phpMailer For sending email. Its working fine on server, but when i am trying to send mail from my local machine(localhost) it giving me error. I am using GMAIL smtp

<?
require("lib/class.phpmailer.php"); 
$mail = new PHPMailer();
$mail->IsSMTP(); 
$mail->SMTPAuth = true;
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465; 
$mail->Username = "XXX@XXX.com";  // SMTP username
$mail->Password = "XXXXXXX"; // SMTP password
$mail->From = $email; 
$mail->AddAddress("XXXXXX@XXX.com", "XX XX XX");
$mail->WordWrap = 50;
$mail->IsHTML(true); 
$mail->Subject = "You have received feedback from your website!";
$mail->Body    = $message;
$mail->AltBody = $message; 
if(!$mail->Send())
 {
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
 }

 }
 ?>

and the error is

SMTP Error: Could not connect to SMTP host. Message could not be sent.

Mailer Error: SMTP Error: Could not connect to SMTP host.

It’s working fine in my server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:30:24+00:00Added an answer on June 11, 2026 at 6:30 pm

    Okay I got it in local here is the code that I used

    <?php
        require("phpmailer/class.phpmailer.php");
        $mail = new PHPMailer();
        $mail->IsSMTP(); // send via SMTP
        IsSMTP(); // send via SMTP
        $mail->SMTPAuth = true; // turn on SMTP authentication
        $mail->Username = "username@gmail.com"; // SMTP username
        $mail->Password = "password"; // SMTP password
        $webmaster_email = "username@doamin.com"; //Reply to this email ID
        $email="username@domain.com"; // Recipients email ID
        $name="name"; // Recipient's name
        $mail->From = $webmaster_email;
        $mail->FromName = "Webmaster";
        $mail->AddAddress($email,$name);
        $mail->AddReplyTo($webmaster_email,"Webmaster");
        $mail->WordWrap = 50; // set word wrap
        $mail->IsHTML(true); // send as HTML
        $mail->Subject = "This is the subject";
        $mail->Body = "This is the HTML BODY "; //HTML Body
        $mail->AltBody = "This is the body when user views in plain text format"; //Text Body
        if(!$mail->Send())
        {
        echo "Mailer Error: " . $mail->ErrorInfo;
        }
        else
        {
        echo "Message has been sent";
        }
        ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have send an email using php mailer class. mail was sending successfully but
I'm using PHPMailer to send email. Everything is working fine except one thing. The
I am trying to send an email from PHP using PHPmailer() . I have
I'm trying to send mail using phpMailer. It's my code: <?php require_once('phpmailer/class.phpmailer.php'); $mail =
I am trying to email a file that exists on my server using PHPMailer.
I wrote some code to send an email from my PHP script using PHPMailer.
I'm trying to send SMTP e-mails using PHPMailer, but I keep getting this error
I'm using phpmailer to send email. But all of my emails are send with
I'm using the PHPMailer-Lite class to build an email sending script and I'm not
I'm trying to accomplish the following, I'm sending a HTML email using PHP Mailer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.