ff代码在本地运行时效果很好,问题是当上传到我们的域名主机时,会抛出此错误
致命错误:未捕获的异常' Swift_TransportException'有消息'预期回复代码250,但得到代码"",带有消息""'
我的理论是主机上的php版本没有更新。
任何想法这个问题的真正原因是什么?这是我的代码。我使用swiftmailer 5.1.0,本地机器的php版本是php 5.6.12
$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. :(';
}