/    Sign up×
Community /Pin to ProfileBookmark

PHPMailer + Gmail – No route to host (113)

Ok So I’m trying to update old code to use SMTP authentication through our GMail hosted company email. I’m running into the following error:

[quote]

SMTP -> ERROR: Failed to connect to server: No route to host (113)
SMTP Error: Could not connect to SMTP host.

[/quote]

My code is (note some things sanitized for public viewing):

[code=php]
$paths = get_include_path();
set_include_path($paths . PATH_SEPARATOR . dirname(__FILE__) . ‘/phpmailer’);
include_once(‘class.phpmailer.php’);
$mail = new phpmailer;

// Constant email settings.
$mail->IsSMTP();
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = “tls”;
$mail->Host = “smtp.gmail.com”;
$mail->Port = 587;
$mail->Username = “–@noas.com”;
$mail->Password = “–“;
$mail->From = “[email protected]”;
$mail->FromName = “NOAS Contact”;
$mail->WordWrap = 75;
$mail->Subject = “10th Anniversary Dave Thomas Celebrity Cookoff – Chef Invite”;
$mail->AddReplyTo(“–@noas.com”, “–“);
$mail->IsHTML(true);
$mail->addBcc(‘–@noas.com’,’–‘);

$mail->SMTPDebug = 2; // For debugging, change to 0 when working

foreach( $emails as $info ) {
$mail->AddAddress($info[’email’], $info[‘name’]);
$mail->msgHTML(buildmsg($info[‘name’]));

// Send mail message to each recipient
if( $mail->Send() )
$content .= ‘Message to ‘. $info[‘name’] .’ sent successfully.<br />’;
else
$content .= ‘Message to ‘. $info[‘name’] .’ failed to send.<br />’;

$mail->clearAddresses();
}
[/code]

I’ve also tried changing to this as in a document included:

[code=php]
$mail->SMTPSecure = “tls”;
$mail->Host = “smtp.gmail.com”;
$mail->Port = 587;
[/code]

I was using [url]http://phpmailer.worxware.com/index.php?pg=examplebgmail[/url] plus the documents included in the ZIP to set up the settings, So I don’t see what’s wrong. Sometimes I get this error instead:

[quote]

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

[/quote]

Either way its not sending emails, Any help would be greatly appreciated =D

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NoasITauthorAug 04.2011 — Woops I mean to say I tried changing to SSL as such:
[code=php]
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
[/code]


To no avail. sorry.
×

Success!

Help @NoasIT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...