我使用以下代码发送消息:
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";
}
问题是它在我的本地服务器(我的 xampp 服务器)上工作正常,但在文件上传到真实服务器上时无法正常工作。
它抛出这个错误:
'The SMTP connection failed to start [mail.somedomain.net:587]: fsockopen returned Error Number 110 and Error String 'Connection timed out''
请问我应该怎么做才能纠正这个错误。谢谢阅读