I want to send a confirmation mail to an user who is trying to register. Iam using PHP Mailer for sending mails. Here is my code:

```
require_once("PHPMailer/class.phpmailer.php");

        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->Host = "localhost";
        $mail->SMTPAuth = true;// turn on SMTP authentication
        $mail->Username = "root";// SMTP username
        $mail->Password = "";// SMTP password
        $mail->SetLanguage("en","PHPMailer/language");

        //compose mail
        $mail->From = "admin@localhost.com";
        $mail->FromName = "Cinema Admin";
        $mail->AddAddress($_POST['email']);
        $mail->AddReplyTo("admin@localhost.com", "Cinema Admin");
        $mail->Subject = 'Your confirmation link here';
        $mail->Body = "Your confirmation link\r\n";
        $mail->Body .= "Click on this link to activate your sccount\r\n";
        $mail->Body .= "http://localhost/user.login_plugin/confirm.php?passkey=$confirm_code"; 

        //send mail
        if (!$mail->Send())
        {
            echo "Message was not sent <p>";
            echo "Mailer Error: " . $mail->ErrorInfo;
            exit;
        }

        echo "Message has been sent";

```

When I execute the file,it says 

```
Message was not sent

Mailer Error: SMTP connect() failed.

```

Could anyone suggest me for sending mails from localhost to the registered user's emailid.
I had searched with few titles regarding "ending emails" in stack overflow, but couldn't find any solution from any posts.

Thank You in advance