PHPMailer/SwiftMailer Send Email - Connection could not be established with host smtp.gmail.com -


i trying send emails via php mailer (upon not working installed , tried swift mailer, , getting same results).

i can send them using localhost goes spam, doing head in. trying send through smtp through gmail account, in hope authenticate email.

here code:

function sendmail( $toemail, $messagehtml, $messagetext ) {   require_once ( '../phpmailer/phpmailerautoload.php' ); // add path appropriate   $mail = new phpmailer();   $mail->issmtp(); // use smtp   $mail->host        = "smtp.gmail.com"; // sets smtp server   $mail->smtpdebug   = 2; // 2 enable smtp debug information   $mail->smtpauth    = true; // enable smtp authentication   $mail->smtpsecure  = "tls"; //secure conection   $mail->port        = 587; // set smtp port   $mail->username    = 'b31tom@gmail.com'; // smtp account username   $mail->password    = 'workingpass'; // smtp account password (ive tried both normal , app passwords)   $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        = 'b31tom@gmail.com';   $mail->fromname    = 'gmail test';   $mail->wordwrap    = 900; // rfc 2822 compliant max 998 characters per line    $mail->addaddress( $toemail ); // to:   $mail->ishtml( true );   $mail->body    = "test";   $mail->altbody = "test";   $mail->send();   $mail->smtpclose();    if ( $mail->iserror() ) { // added - error checking missing     return false;   }   else {     return true;   } }  $toemail = 'b31tom@me.com'; $toname  = 'name';  $send = sendmail( $toemail, $messagehtml, $messagetext ); if ( $send ) {   echo "<h2> sent ok</h2>"; } else {   echo "<h2> error</h2>"; } die; 

this returns following error:

2014-12-16 13:17:14 smtp error: failed connect server: network unreachable (101) 2014-12-16 13:17:14   smtp connect() failed. error 

i have contacted web provider check following: openssl enabled fopen enabled ports 465 , 587 open

i have gone through numerous example codes both php mailer , swift mailer (which claim working code!) , give same result. error 101 cannot connect gmail server!

i have support ticket open web provider , have people looking there , can't see issue either.

help please :(

right @ moment, gmail smtp servers appear having widespread outages morning. don't know code:) searching others having issues. re-try later.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -