phpmailer отправить gmail smtp timeout

Возможный дубликат:
Проблемы с PHPMailer

Вопросов много, но никто из них не помог мне.

Вот мой сценарий, который представлен в примерах phpmailer:

require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch $mail->IsSMTP(); // telling the class to use SMTP try { $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "yourusername@gmail.com"; // GMAIL username $mail->Password = "yourpassword"; // GMAIL password $mail->AddReplyTo('name@yourdomain.com', 'First Last'); $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); $mail->SetFrom('name@yourdomain.com', 'First Last'); $mail->AddReplyTo('name@yourdomain.com', 'First Last'); $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail->MsgHTML("some message"); $mail->Send(); echo "Message Sent OK</p>\n"; } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } 

и вот ошибка:

 SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP Error: Could not connect to SMTP host. 

во многих вопросах было упомянуто, чтобы включить php_openssl extenstion который включен на моем сервере. Я использую PHPmailer версии 5.1

также нет проблем с моим портом сервера 25, а простая функция mail() работает нормально

Спасибо за вашу помощь

Вот рабочий пример:

  require_once ( 'class.phpmailer.php' ); // Add the path as appropriate $Mail = new PHPMailer(); $Mail->IsSMTP(); // Use SMTP $Mail->Host = "smtp.gmail.com"; // Sets SMTP server $Mail->SMTPDebug = 2; // 2 to enable SMTP debug information $Mail->SMTPAuth = TRUE; // enable SMTP authentication $Mail->SMTPSecure = "tls"; //Secure conection $Mail->Port = 587; // set the SMTP port $Mail->Username = 'MyGmail@gmail.com'; // SMTP account username $Mail->Password = 'MyGmailPassword'; // SMTP account password $Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low) $Mail->CharSet = 'UTF-8'; $Mail->Encoding = '8bit'; $Mail->Subject = 'Test Email Using Gmail'; $Mail->ContentType = 'text/html; charset=utf-8\r\n'; $Mail->From = 'MyGmail@gmail.com'; $Mail->FromName = 'GMail Test'; $Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line $Mail->AddAddress( $ToEmail ); // To: $Mail->isHTML( TRUE ); $Mail->Body = $MessageHTML; $Mail->AltBody = $MessageTEXT; $Mail->Send(); $Mail->SmtpClose(); if ( $Mail->IsError() ) { echo "ERROR<br /><br />"; } else { echo "OK<br /><br />"; }