duanguilin2007 2018-12-06 03:58
浏览 30

我使用PHP版本5.2。 该脚本在000webhost中工作,但是当我使用雅虎网络主机时,它不起作用

Can someone help why my script is not working in yahoo web host, but it is working in 000webhost. Im using phpmailer5.2 and Phpversion 5.2.12

The error is Connection failed. Error #2: stream_socket_client() [function.stream-socket-client]: unable to connect to smtp.gmail.com:587 (No route to host) [/products/phpmailer/class.smtp.php line 304] 2018-12-06 03:50:16 SMTP ERROR: Failed to connect to server: No route to host (65) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

<?php
$result="";
if (isset($_POST['submit'])) {
require_once ('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer;

$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;
$mail->SMTPSecure='tls';
$mail->Username='sample@gmail.com';
$mail->Password='';

$mail->setFrom($_POST['email'],$_POST['name']);
$mail->addAddress('');
$mail->addAddress('');
$mail->addAddress('');
$mail->addReplyTo($_POST['email'],$_POST['name']);

$mail->isHTML(true);
$mail->Subject='Form Submission: '.$_POST['subject'];
$mail->Body='<h1 align=center>Name: '.$_POST['name'].'<br>Email: ' .$_POST['email']. '<br>Company: ' .$_POST['company'].'<br>Position: ' .$_POST['position'].'<br>Current System Used: '.$_POST['system']. '<br>Message: ' .$_POST['msg'].'</h1>';

if (!$mail->send()) {

  $result="Something went wrong please try again.";

}
else{

  $result="Thanks ".$_POST['name']." sending your request. ";
}

}

?>
  • 写回答

1条回答 默认 最新

  • duanjie9630 2018-12-06 04:32
    关注

    The error is clear on your post.

    You have a "no route to host", so, the problem are your web hosting have blocked you to connect to gmail servers.

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line