SMTP错误:无法连接到SMTP主机 - 即使在启用openssl

时间:2017-01-16 07:27:32

标签: javascript php jquery html css

我收到以下错误:(我知道这是一个常见问题)

  

SMTP - >错误:无法连接到服务器:连接尝试失败,因为连接方在a之后没有正确响应   一段时间,或建立的连接失败,因为连接   主持人没有回复。 (10060)SMTP错误:无法连接   SMTP主机。

我正在使用xampp并已启用:

extension=php_openssl.dll

我的php:



<?php
if(isset($_POST['submit'])) {
    $message= 'Full Name:	'.$_POST['fullname'].'<br />
    Email:	'.$_POST['emailid'].'<br />
    Subject:	'.$_POST['subject'].'<br />
    Comments:	'.$_POST['comments'].'';
    require "phpmailer/class.phpmailer.php"; //include phpmailer class

    // Instantiate Class
    $mail = new PHPMailer();

    // Set up SMTP
    $mail->SMTPDebug = 1;
    $mail->IsSMTP();                // Sets up a SMTP connection
    $mail->SMTPAuth = true;         // Connection with the SMTP does require authorization
    $mail->SMTPSecure = 'ssl';      // Connect using a TLS connection
    $mail->Host = "smtp.gmail.com";  //Gmail SMTP server address
    $mail->Port = 465;  //Gmail SMTP port
    $mail->Encoding = '7bit';

    // Authentication
    $mail->Username   = "xxxxxxx"; // Your full Gmail address
    $mail->Password   = "xxxxxx"; // Your Gmail password

    // Compose
    $mail->SetFrom($_POST['emailid'], $_POST['fullname']);
    $mail->AddReplyTo($_POST['emailid'], $_POST['fullname']);
    $mail->Subject = "New Contact Form Enquiry";      // Subject (which isn't required)
    $mail->MsgHTML($message);

    // Send To
    $mail->AddAddress("xxxxxxxxxx", "Recipient Name"); // Where to send it - Recipient
    $result = $mail->Send();		// Send!
	$message = $result ? 'Successfully Sent!' : 'Sending Failed!';
	unset($mail);
}
?>
&#13;
&#13;
&#13;

注意:当我将其加载到不同的服务器时,它工作正常。 http://79.170.40.183/maprofile.com/

0 个答案:

没有答案