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. :(';
}