0
votes

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='[email protected]';
$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
Both the version of PHPMailer you're using, and the version of PHP are extremely outdated, and your site is vulnerable to attack as a result. Upgrade both, now.Synchro

1 Answers

0
votes

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.