Page 1 of 1

Question on moving from phpmailer to swiftmailer

Posted: Sun Jan 04, 2009 9:03 pm
by sjncdogsrule
I am getting the following error when connecting to the SMTP server (note my ISP only has PHP 4.4.4)

Uncaught Error of type [swift_connectionexception] with message [Authentication failed using username '****' and password '********']

When using phpmailer, I use the exact same id and password and the e-mail is sent. Below is a the phpmailer code:

Code: Select all

   $mail = new PHPMailer();
    $mail->SetLanguage('en');
  
    $mail->IsSMTP();                   // set mailer to use SMTP
    $mail->Host     = $vdc_smtp_host;  // specify main and backup server
    $mail->SMTPAuth = true;            // turn on SMTP authentication
    $mail->Username = $vdc_smtp_user;  // SMTP username
    $mail->Password = $vdc_smtp_pass;  // SMTP password
  
    $mail->From     = $admin_email;
    $mail->FromName = "Me";
    $mail->AddReplyTo($admin_email, "Me");
    $mail->WordWrap = 70;     // set word wrap to 70 characters
    $mail->IsHTML(false);     // set email format to plain text
  
    $mail->Subject = $subject;
    $mail->Body    = $body;
    $mail->AddAddress("you@yourdomain.org","You");
    $mail->AddAddress("you2@yourdomain.org","You2");
    $mail->Send();
And the relevant swiftmailer code. Note using same variables for username and password:

Code: Select all

    require_once "swiftmail_lib/Swift.php";
    require_once "swiftmail_lib/Swift/Connection/SMTP.php";
    
    $smtp =& new Swift_Connection_SMTP($vdc_smtp_host,25);
    $smtp->setUsername($vdc_smtp_user);
    $smtp->setPassword($vdc_smtp_pass);
   
    $swift =& new Swift($smtp);
   
    $message =& new Swift_Message($subject, $body);
  
    $recipients =& new Swift_RecipientList();
    $recipients->addTo("you@yourdomain.org","you");
    $recipients->addTo("you2@yourdomain.org","you2");
    $swift->batchSend($message, $recipients, $admin_email);
Thanks for any help!
-- Scott

Re: Question on moving from phpmailer to swiftmailer

Posted: Mon Jan 05, 2009 12:23 am
by Chris Corbyn
Are you able to provide the details of your SMTP server so I can take a look at which auth method it's trying to use? We can't have PHPMailer doing something Swift Mailer won't do ;) Then again I haven't been writing PHP4 code for around a year now and I'm not likely to I'm afraid.

Is there a reason your host can't move to PHP5? I'd certainly pressure them to do so given the fact it's no longer supported by Zend and hasn't been supported for over a year.

Re: Question on moving from phpmailer to swiftmailer

Posted: Mon Jan 05, 2009 8:29 am
by sjncdogsrule
I've put in a support ticket with my hosting company about php version 5.

As for details of SMTP, from phpinfo() I get the following:
SMTP localhost
smtp_port 25

That's the only things about SMTP returned from phpinfo(). Where else should I look?

-- Scott

Re: Question on moving from phpmailer to swiftmailer

Posted: Mon Jan 05, 2009 11:58 pm
by Chris Corbyn
Ah, if it's localhost I can't really connect to it. I was hoping for a web-facing hostname or IP address I could telnet to :)

Re: Question on moving from phpmailer to swiftmailer

Posted: Tue Jan 06, 2009 8:19 am
by sjncdogsrule
But in the code I use:
$smtp =& new Swift_Connection_SMTP($vdc_smtp_host,25);

$vdc_smtp_host is not set to localhost. Its set to my website domain smtp domain name, the same thing I can use in Outlook Express or Thunderbird.

What is it you are looking for?

-- Scott

Re: Question on moving from phpmailer to swiftmailer

Posted: Wed Jan 07, 2009 10:48 am
by sjncdogsrule
Interestingly enough, I commented out my userid and password so swiftmailer did not do authentication, and everything worked.

Does anyone find it odd that I would not need to supply a user id or password to send e-mail? Seems like if anybody knew the server, anybody could send e-mail thru the server and appear to come from my domain?

-- Scott

Re: Question on moving from phpmailer to swiftmailer

Posted: Thu Jan 08, 2009 11:09 pm
by Chris Corbyn
sjncdogsrule wrote:Interestingly enough, I commented out my userid and password so swiftmailer did not do authentication, and everything worked.

Does anyone find it odd that I would not need to supply a user id or password to send e-mail? Seems like if anybody knew the server, anybody could send e-mail thru the server and appear to come from my domain?

-- Scott
SMTP servers usually check where you're calling from. If you're in the correct domain then they usually don't use authentication.