Page 1 of 1

How to code for "My server requires authentication"

Posted: Sat Feb 28, 2009 11:03 pm
by henriemedia
I am sorry if this is a stupid question, but I just can't figure it out. I am trying to determine what code I need to use to perform that same function as checking the "My server requires authentication" box in Outlook when setting up an account.

Here is the code I have -

Code: Select all

 
require_once "swiftmailer-library/Swift.php";
require_once "swiftmailer-library/Swift/Connection/SMTP.php";
$smtp =& new Swift_Connection_SMTP(**SMTPSERVER**, **PORT**);
$smtp->setUsername(**USERNAME**);
$smtp->setpassword(**PASSWORD**);
$swift =& new Swift($smtp);
 
I know I have all of the **-** variables correct. But the problem I have is I keep getting this error -

Code: Select all

 
Fatal error:
Uncaught Error of type [Swift_ConnectionException] with message [Authentication failed using username '**USERNAME**' and password '*********']
@0 Swift::Swift() in admin-send-email.php on line 100
@1 Swift::connect() in /swiftmailer-library/Swift.php on line 109
@2 Swift::handshake() in /swiftmailer-library/Swift.php on line 230
 
I just need to perform the same function as the "My server requires authentication" box in Outlook when setting up an account.

Any help would be greatly appreciated. Thank you.

Re: How to code for "My server requires authentication"

Posted: Sun Mar 01, 2009 3:34 am
by Chris Corbyn
It's possible that your username and password only work when connecting from certain domains. Most definitely your username and password are not being accepted when connecting from your web server. Your code is correct. Have you tried without the username and password and are you sure you're using the correct server for that domain? For example, my home ISP is with BigPond here in Australia, but that doesn't mean that I can connect to BigPond's SMTP server from my web hosting account elsewhere. The credentials only work when I'm connected to my home router.