dongyu9263 2017-03-18 10:50
浏览 119

Swiftmailer网关超时错误

I am getting Gateway timeout error when using swiftmailer on hosted server. But on my PC localhost, its works fine.

When I informed to my hosting, they said they have enabled the outbound connection to port no 465.

Script I have used.

$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];

require_once 'mailer/lib/swift_required.php';

// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername('myemail@gmail.com')
    ->setPassword('myapppassword')
;

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance()

->setSubject('New Message From ' . $name)
->setFrom(array($email => '$name'))
->setReplyTo($email)
->setTo(array('myemail@gmail.com' => 'My Name'))
->setBody($message)
->addPart('Message: <b>'. $message .'</b>', 'text/html')
;

$result = $mailer->send($message);

if(!$result) {
    echo $msg = 'Oops. Something went wrong. Please try again later.';
} else {
    echo $msg = 'Thank you. Your query has been submitted. We will contact you back through the provided email address.';

}

Above code used only for hiding headers. But headers are used in order to direct.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料