[SOLVED] Setup Mail Problems - Error (Yahoo's SMTP)

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
chazter6
Forum Newbie
Posts: 9
Joined: Thu Apr 12, 2007 1:38 pm

[SOLVED] Setup Mail Problems - Error (Yahoo's SMTP)

Post by chazter6 »

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]


My particulars:
LocalTest Machine:
Win XP Pro, Apache 1.3.31, PHP 4.3.11, SwiftMailer 3.1.3-php4

Extracted the contents to c:\website\SwiftMailer

Edit PHP.ini file to set the include_path to c:\website\SwiftMailer\lib

Problem:  Trying to setup a test machine within my company to test e-mails for a website to send out e-mails.  I would like to test the setup using a personal account from yahoo.

My basic testemail.php code:

Code: Select all

ini_set('display_errors', '1'); 
error_reporting(E_ALL);

require_once ("Swift.php");
require_once ("Swift/Connection/SMTP.php");
 
//Start Swift
$smtp =& new Swift_Connection_SMTP("smtp.mail.yahoo.com");
$smtp->setUsername("changeToUser");
$smtp->setPassword("changeToPassword");

$swift =& new Swift($smtp);

//Create the message
$message =& new Swift_Message("My subject", "My body");
 
//Now check if Swift actually sends it
if ($swift->send($message, "im_chaz@rocketmail.com", "cbernardes@gvnw.com")) echo "Sent";
else echo "Failed";
Now when I run this on my local machine at http://localhost:8080/testemail.php, I get the following errors on the page.

Code: Select all

Fatal error:
Uncaught Error of type [swift_badresponseexception] with message [Expected response code(s) [250] but got response [535 authorization failed (#5.7.0)]]
@0 swift::swift() in c:\website\testemail.php on line 17
@1 swift::connect() in c:\website\SwiftMailer\lib\Swift.php on line 109
@2 swift::handshake() in c:\website\SwiftMailer\lib\Swift.php on line 243
@3 swift_connection_smtp::postconnect() in c:\website\SwiftMailer\lib\Swift.php on line 297
@4 swift_connection_smtp::runauthenticators() in c:\website\SwiftMailer\lib\Swift\Connection\SMTP.php on line 340

in c:\website\SwiftMailer\lib\Swift\Errors.php on line 99
I am totally new at this and would love any assistance. I have tried going through most of the messages but I am at a lost. I appreciate any feedback.

Thanks in advance,


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]
Last edited by chazter6 on Thu Apr 12, 2007 3:00 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It says authorization failed (535). Can you confirm this username and password are indeed correct?

Some servers don't even require a username and password... what happens if you try without?
chazter6
Forum Newbie
Posts: 9
Joined: Thu Apr 12, 2007 1:38 pm

Post by chazter6 »

Thanks for the quick response.

Yes, I have confirmed my Username and Password is correct.

if I change my code to this...

Code: Select all

$smtp =& new Swift_Connection_SMTP("smtp.mail.yahoo.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
I get these messages...

Code: Select all

Fatal error:
Uncaught Error of type [swift_connection_exception] with message [The SMTP connection failed to start [tls://smtp.mail.yahoo.com:465]: fsockopen returned Error Number 0 and Error String 'The operation completed successfully. ']
@0 swift::swift() in c:\website\testemail.php on line 20
@1 swift::connect() in c:\website\SwiftMailer\lib\Swift.php on line 109

in c:\website\SwiftMailer\lib\Swift\Errors.php on line 99
Am I making progress? Or is it getting worse and I should revert to my previous code?

Thanks,
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

No you don't need to edit php.ini to run SwiftMailer ;)

The error is basically the SMTP server saying it's rejecting your username and password so this is odd.

Private Message me the output of this debug code (it contains sensitive info so don't post it here):

Code: Select all

require_once ("Swift.php"); 
require_once ("Swift/Connection/SMTP.php"); 

function handle_error($errno, $errstr, $errfile, $errline)
{
  $swift =& $GLOBALS["swift"];
  echo "<pre>" . $swift->log->dump() . "</pre>";
  exit(1);
}

set_error_handler("handle_error");

//Start Swift 
$smtp =& new Swift_Connection_SMTP("smtp.mail.yahoo.com"); 
$smtp->setUsername("changeToUser"); 
$smtp->setPassword("changeToPassword"); 

$swift =& new Swift($smtp, null, SWIFT_ENABLE_LOGGING);
Obviously you'll need to set the username and password again :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

This was solved via PM. Yahoo does not provide message relaying just because you have a Yahoo email account; their MX server is just for receiving mail to Yahoo accounts.
Post Reply