Swift Mailer Error

Posted by Selom on Stack Overflow See other posts from Stack Overflow or by Selom
Published on 2010-04-07T19:07:17Z Indexed on 2010/04/07 20:13 UTC
Read the original article Hit count: 561

Filed under:
|

Hi, Im using the following code to send a message:

try
{   
    require_once "lib/Swift.php";
    require_once "lib/Swift/Connection/SMTP.php";
    $smtp =& new Swift_Connection_SMTP("mail.somedomain.net", 587);
    $smtp->setUsername("username");
    $smtp->setpassword("password");
    $swift =& new Swift($smtp);

    //Create the sender from the details we've been given
    $sender =& new Swift_Address($email, $name);
    $message =& new Swift_Message("message title");

    $message->attach(new Swift_Message_Part("Hello"));

    //Try sending the email
    $sent = $swift->send($message, "$myEmail", $sender);
    //Disconnect from SMTP, we're done
    $swift->disconnect();

    if($sent)
    {
        print 'sent';

    }
    else 
    {
        print 'not sent';
    }

}

catch (Exception $e) 
{
    echo"$e";
}

The issue is that it is working fine on my local server (which my xampp server) but not working when the file is uploaded on the real server.

It throwing this error:

'The SMTP connection failed to start [mail.somedomain.net:587]: fsockopen returned Error Number 110 and Error String 'Connection timed out''

Please what should I do to correct this error. Thanks for reading

© Stack Overflow or respective owner

Related posts about swiftmailer

Related posts about php