How to code for "My server requires authentication"

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
henriemedia
Forum Newbie
Posts: 1
Joined: Sat Feb 28, 2009 10:56 pm

How to code for "My server requires authentication"

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

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

Post 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.
Post Reply