0
的FF代码工作完全当本地运行,问题是,当上传到我们的域名主机,它抛出这个错误Swiftmailer错误220
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Expected response code 250 but got code "", with message ""'
我的理论是,主机上的PHP版本没有更新。
任何想法这个问题的真正原因是什么?这是我的代码。我使用swiftmailer 5.1.0和我的本地机器的PHP版本是5.6.12 PHP
$smtp_host_ip = gethostbyname('our_domain_host.ph');
#set the transport
$emailuser1 = $_SESSION['email'];
$transport = Swift_SmtpTransport::newInstance($smtp_host_ip,587,'tls')->setUsername('username.ph')->setPassword('password');
// Mailer
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Thank you for answering the survey')
->setFrom(array('username.ph' => 'Test'))
->setTo(array($_SESSION['receive_email'] => 'Receiver Name'))
->setBody($_SESSION['reply_guest']);
// Send the message
if ($mailer->send($message)) {
echo 'Mail sent successfully.';
} else {
echo 'I am sure, your configuration are not correct. :(';
}