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 8533541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:59:02+00:00 2026-06-11T09:59:02+00:00

Using PHPMailer http://phpmailer.worxware.com/index.php?pg=examples how can I test if my SMTP settings are working, without

  • 0

Using PHPMailer http://phpmailer.worxware.com/index.php?pg=examples how can I test if my SMTP settings are working, without actually sending an email?

Edit: Maybe I should make this more generic, and just ask how I check a SMTP connction using PHP, without sending an email.

  • 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-11T09:59:03+00:00Added an answer on June 11, 2026 at 9:59 am

    If you are using PHPMailer, you can use the Connect() method, before sending, and check for errors if the connection is not correct.

      /**
      * Connect to the server specified on the port specified.
      * If the port is not specified use the default SMTP_PORT.
      * If tval is specified then a connection will try and be
      * established with the server for that number of seconds.
      * If tval is not specified the default is 30 seconds to
      * try on the connection.
      *
      * SMTP CODE SUCCESS: 220
      * SMTP CODE FAILURE: 421
      * @access public
      * @return bool
      */
      public function Connect($host, $port = 0, $tval = 30) {
        // set the error val to null so there is no confusion
        $this->error = null;
    
        // make sure we are __not__ connected
        if($this->connected()) {
          // already connected, generate error
          $this->error = array("error" => "Already connected to a server");
          return false;
        }
    
        if(empty($port)) {
          $port = $this->SMTP_PORT;
        }
    
        // connect to the smtp server
        $this->smtp_conn = @fsockopen($host,    // the host of the server
                                      $port,    // the port to use
                                      $errno,   // error number if any
                                      $errstr,  // error message if any
                                      $tval);   // give up after ? secs
        // verify we connected properly
        if(empty($this->smtp_conn)) {
          $this->error = array("error" => "Failed to connect to server",
                               "errno" => $errno,
                               "errstr" => $errstr);
          if($this->do_debug >= 1) {
            echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
          }
          return false;
        }
    
        // SMTP server can take longer to respond, give longer timeout for first read
        // Windows does not have support for this timeout function
        if(substr(PHP_OS, 0, 3) != "WIN")
          socket_set_timeout($this->smtp_conn, $tval, 0);
    
        // get any announcement
        $announce = $this->get_lines();
    
        if($this->do_debug >= 2) {
          echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
        }
    
        return true;
      }
    

    (From PHPMailer SVN)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using google, yahoo and AOL smtp and PHPMailer how many mails can be sent
I am working on a PHP based mailing list using PHPmailer. Currently I have
using PHPMailer's AddAttachment method on PHP 5, it seems I can't get any mail
I'm trying to send mail using phpMailer. It's my code: <?php require_once('phpmailer/class.phpmailer.php'); $mail =
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I'm using PHPMailer and it uses fsockopen to access the SMTP server. But the
I'm using PHPMailer to send email from PHP. My email body contains HTML format
I'm trying to test the PHPmailer class to embed image (http://www.google.gr/intl/en_com/images/srpr/logo1w.png) inside an e-mail
I'm using PHPMailer to send email. Everything is working fine except one thing. The
Ive been working on create a file upload form using PHPmailer to send as

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.