The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

fsockopen() error in class.smtp.php

Discussion in 'E-mail Discussions' started by onkar, Dec 13, 2007.

  1. onkar

    onkar Member

    Joined:
    Jul 9, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    We are facing an issue while sending mails through php script. Following are the error details.

    Warning: fsockopen() [function.fsockopen]: unable to connect to mail.domain.com:25 in /home/user/public_html/mail/class.smtp.php on line 122

    Message was not sent

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

    We are using following script for sending mails.

    <?php
    require_once("class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP(); // send via SMTP
    $mail->Host = "mail.domain.com"; // SMTP servers
    #$mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "user@domain.com"; // SMTP username
    $mail->Password = "xxxx"; // SMTP password
    $mail->From = "user@domain.com";
    $mail->FromName = "user";
    $mail->AddAddress("user@yahoo.com");
    $mail->WordWrap = 50; // set word wrap
    $mail->IsHTML(true); // send as HTML
    $mail->Subject = "Hi";
    $mail->Body = "How are you";
    if(!$mail->Send())
    {
    echo "Message was not sent <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
    }

    echo "Message has been sent";
    ?>

    Please let us know the solution for this error.

    Thanks,
    Onkar
     
  2. LuisMello

    LuisMello Member

    Joined:
    May 30, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I have the same problem
     
  3. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Can you telnet to the remote host port 25?
     
  4. Kailash1

    Kailash1 Well-Known Member

    Joined:
    Nov 27, 2006
    Messages:
    252
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi,

    I have the same problem and I am able to connect to server remotely via telnet using port 25.

    Thanks,

    Kailash
     
  5. Kailash1

    Kailash1 Well-Known Member

    Joined:
    Nov 27, 2006
    Messages:
    252
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi,

    I could successfully resolve the issue by downgrading Apache version to 1.3 and PHP version to PHP 4.4.8. I am not sure it was a problem with Apache or PHP version.

    Kailash
     
Loading...

Share This Page