SMTP Authentication problem

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
mxiong
Forum Newbie
Posts: 3
Joined: Tue Sep 25, 2007 1:50 pm

SMTP Authentication problem

Post by mxiong »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I can't seem to connect using SMTP Authentication.  The error I keep getting is that it cannot connect to the server and connection is timing out.  This is what I have for my code:

Code: Select all

//Load in the files we'll need 
require_once "lib/swift/Swift.php"; 
require_once "lib/swift/Swift/Connection/SMTP.php"; 
require_once "lib/swift/Swift/Authenticator/LOGIN.php"; 

//Start Swift 
$conn =& new Swift_Connection_SMTP("mail.myserver.tld", 25); 
$conn->setUsername("myusername"); 
$conn->setPassword("mypassword"); 
$swift =& new Swift($conn);
Am I just missing this part:

Code: Select all

$conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
If that's not the case, then what can it be? I am positive that username and pw are correct, as well as mail server address and port. Please help.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

If it's timing out it's got nothing to do with authentication and more to do with network restrictions in place on your hosting account. Who's your host? GoDaddy are a no-go for one.
mxiong
Forum Newbie
Posts: 3
Joined: Tue Sep 25, 2007 1:50 pm

Post by mxiong »

No, I am not hosting through GoDaddy.

Here's what I have:
$smtp =& new Swift_Connection_SMTP(mailserver", PortNumber);
$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());
$smtp->setUsername("username");
$smtp->setPassword("password");
$smtp->setTimeout(60);


I changed the timeout seconds because I wanted to see what happens. When I run this, I get nothing back. My code stops executing at exactly 30 seconds even with time out set to 60.

When I remove the setTimeout(), this is the error I get:
Fatal error:
Uncaught Error of type [Swift_Connection_Exception] with message [The SMTP connection failed to start [mailserver:PortNumber]: fsockopen returned Error Number 110 and Error String 'Connection timed out']
@0 Swift::Swift() in blahblahblah on line 23
@1 Swift::connect() in blahblahblah on line 109

in /home/mxiong/public_html/npd/swift/Swift/Errors.php on line 99


Before, I used a Pop before SMTP and the connect worked fine....this was up until the mail server was changed to smtp authentication.


Any help would be great.
chuckl
Forum Commoner
Posts: 61
Joined: Wed May 23, 2007 7:36 am

Post by chuckl »

Connect with telnet or similar to that machine on the port you're using, amd issue an EHLO command.

It should then send back a 'feature list' of what it supports and that'll let you see what authentication it wants.
mxiong
Forum Newbie
Posts: 3
Joined: Tue Sep 25, 2007 1:50 pm

Post by mxiong »

d11wtq was right. It was related to my host provider. I was requested to use a particular port number for using the mail server that I was using. Because of this, my host provider had to open up that port. Once they did that my problem was resolved.

Thanks for the help!!!
Post Reply