Phpmailer给出SMTP错误


Phpmailer giving SMTP ERROR

我收到了这个错误消息。你能帮帮我吗?

我的电子邮件.php;

<?php
header('Content-Type: text/html; charset=utf-8');
require 'PHPMailerAutoload.php';
$phpmailer = new PHPMailer;
$phpmailer->isSMTP();
$phpmailer->Host = 'mail.coffeewritingcontent.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'iletisim@coffeewritingcontent.com';
$phpmailer->Password = 'mypassword';
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Port = '587';
$phpmailer->From = 'iletisim@coffeewritingcontent.com';
$phpmailer->FromName = $_POST['name'];
$phpmailer->AddReplyTo($_POST['email'], $_POST['name']);
$phpmailer->addAddress('iletisim@coffeewritingcontent.com', 'İletişim Formu');
$phpmailer->isHTML(true);
$phpmailer->Subject = 'İletisim formu mesajı';
$phpmailer->Body    = "isim: " . $_POST['name'] . "'r'n'r'nMesaj: " . stripslashes($_POST['message']);
$phpmailer->CharSet = 'UTF-8';
$phpmailer->SMTPDebug = 4;
if(!$phpmailer->send()) {
   echo 'Mail gonderilemedi. Hata: ' . $phpmailer->ErrorInfo;
   exit;
}
echo 'Mail gonderildi.';
?>

我的错误;

2016-03-26 21:52:59连接:打开mail.coffeewritetingcontent.com:587,timeout=10,options=array()2016-03-26 21:53:09 SMTP错误:无法连接到服务器:连接超时(110)邮件服务。错误:语言字符串未能加载:connect_host

请尝试此代码。我现在在GoDaddy的服务器上使用,一切都很好。请确保需要带有require_one实例的php库

            $mail = new PHPMailer;
            $mail->isSMTP();                                      // Set mailer to use SMTP
            $mail->Host = 'localhost';  // Specify main and backup SMTP servers
            $mail->SMTPAuth = true;                               // Enable SMTP authentication
            $mail->Username = 'mymail@mydomain.com';                 // SMTP username
            $mail->Password = 'password';                           // SMTP password
            $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
            $mail->Port = 25;                                    // TCP port to connect to
            $mail->setFrom('mymail@mydomain.com', 'Name');
            $mail->addAddress($email); 
            $mail->isHTML(true); 
            $mail->setLanguage('es');
            $mail->CharSet = 'UTF-8';   
            $mail->Subject = 'Welcome!';
            $mail->Body  = 'This is a messagge test!';
            if ( !$mail->send() ) :
                echo 'Error while sending mail.';
             else :
                echo 'The messagge send correctly';
            endif;

在执行所有这些代码之前,您是否创建了$phpmailer的即时版本?也许你必须这样做。所以,如果你已经这样做了,请查看你的文件PHPMailerAutoload.php,并确保你的文件夹中有phpmailer在下载内容后提供给我们的所有完整文件。我将向您展示一个从phpmailer发送电子邮件的正确代码示例。

require_once('../class.phpmailer.php');
$mail             = new PHPMailer(); // defaults to using php "mail()"
$body             = file_get_contents('contents.html');
$body             = eregi_replace("[']",'',$body);
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");
$mail->Subject    = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

也请确保您从已经上传的服务器发送电子邮件。如果您使用的是像XAMPP这样的虚拟服务,请查看此页面以启用smtp配置:如何配置XAMPP从localhost发送邮件?

问候。