Page 2 of 2

Posted: Mon Aug 13, 2007 2:02 pm
by Chris Corbyn
evilernie wrote:so how do i fix that? create the instance outside of the try ?
No, nothing has been logged because Swift_Connection_SMTP() throws an exception that it couldn't connect, therefore $swiftb is never created.

I'm working on a solution right now and (no promises) may have version 3.3 out in a few hours. In version 3.3 there will be a globally accessible logger, enhanced information in the exceptions if logging is turned on and different levels of logging. Basically you've be able to do this:

Code: Select all

Swift_LogContainer::getLog()->setLogLevel(Swift_Log::LOG_EVERYTHING);

try {
 //
} catch (...) {
  Swift_LogContainer::getLog()->dump();
}
I'm literally writing the code now, but thankfully it's a simple change. I've been living out of subversion way too long so a release will happen tonight hopefully. Sadly some of the other features I wanted to add to v3.3 will have to wait a little longer since I've been too busy to implement them.

Posted: Mon Aug 13, 2007 3:27 pm
by evilernie
sorry to keep bugging you like this but the following code, where the if statement is, the swift->send is failing and i can't figure out why its not sending
any ideas?

Code: Select all

try {
//Create a Swift instance
$swift = new Swift(new Swift_Connection_SMTP("artintheage.com"));

//Create the sender from the details we've been given
$sender = new Swift_Address($email, $name);

//Create the message to send
$message = new Swift_Message("AAMR Comment");
$message->attach(new Swift_Message_Part($body));

//Try sending the email
if($sent = $swift->send($message, $to, $sender)) echo "Sent"; else echo "Failed";

//Disconnect from SMTP, we're done
$swift->disconnect();

} catch (Swift_Connection_Exception $e) {
	
	echo "There was a problem communicating with SMTP: ".$e->getMessage();
}

Posted: Mon Aug 13, 2007 3:29 pm
by Chris Corbyn
Is it failing in the sense that it never runs, or is it always printing "Failed" ?

Posted: Mon Aug 13, 2007 3:30 pm
by evilernie
well its not sending the message at all, so its printing failed.

Posted: Mon Aug 13, 2007 3:35 pm
by Chris Corbyn
evilernie wrote:well its not sending the message at all, so its printing failed.
What does this show?

Code: Select all

try { 
//Create a Swift instance 
$swift = new Swift(new Swift_Connection_SMTP("artintheage.com"), null, Swift::ENABLE_LOGGING); 

//Create the sender from the details we've been given 
$sender = new Swift_Address($email, $name); 

//Create the message to send 
$message = new Swift_Message("AAMR Comment"); 
$message->attach(new Swift_Message_Part($body)); 

//Try sending the email 
if($sent = $swift->send($message, $to, $sender)) echo "Sent"; else echo "Failed";

echo "<pre>";
$swift->log->dump();
echo "</pre>";

//Disconnect from SMTP, we're done 
$swift->disconnect(); 

} catch (Swift_Connection_Exception $e) { 
        
        echo "There was a problem communicating with SMTP: ".$e->getMessage(); 
}

Posted: Mon Aug 13, 2007 3:37 pm
by evilernie

Code: Select all

++ Enabling logging
++ Trying to connect...
<< 220 rm-003-12.serve.com ESMTP Sendmail 8.13.1/8.13.1; Mon, 13 Aug 2007 16:59:15 -0400
>> EHLO [65.23.157.182]
<< 250-rm-003-12.serve.com Hello rm-003-12.serve.com [65.23.157.182] (may be forged), pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>> MAIL FROM: 
<< 250 2.1.0 ... Sender ok
>> RCPT TO: 
<< 550 5.7.1 ... Relaying denied. IP name possibly forged [65.23.157.182]
!! Expected response code(s) [250] but got response [550 5.7.1 ... Relaying denied. IP name possibly forged [65.23.157.182]]
>> RSET
<< 250 2.0.0 Reset state

Posted: Mon Aug 13, 2007 3:39 pm
by Chris Corbyn
Relaying denied. IP name possibly forged [65.23.157.182]
The server is denying to send a message from your IP address. You'll have to check this with your host ;)

Posted: Tue Aug 14, 2007 12:04 pm
by evilernie
ok I contacted my server admin and he said that enabling pop before smtp would fix it, so then i figured i could use swifts popb4smtp but alas, i still get the authentication error... Here is the code im using:

Code: Select all

require_once "/var/www/aamr/swift/Swift.php";
require_once "/var/www/aamr/swift/Swift/Connection/SMTP.php";
require_once "/var/www/aamr/swift/Swift/Authenticator/\$PopB4Smtp\$.php"; 
try {

	$smtp = new Swift_Connection_SMTP("artintheage.com", null, Swift::ENABLE_LOGGING);
	$smtp->attachAuthenticator( new Swift_Authenticator_PopB4Smtp("artintheage.com"));
	$smtp->setUsername("user");
	$smtp->setPassword("pass");
	
	//Create a Swift instance
	$swift = new Swift($smtp);
	
	//Create the sender from the details we've been given
	$sender = new Swift_Address($email, $name);
	
	//Create the message to send
	$message = new Swift_Message("AAMR Comment");
	$message->attach(new Swift_Message_Part($body));
	
	//Try sending the email
	$sent = $swift->send($message, "markh@gyroworldwide.com", $sender);
	
	echo "<pre>";
	$swift->log->dump();
	echo "</pre>";
	
	//Disconnect from SMTP, we're done
	$swift->disconnect();

} catch (Swift_Connection_Exception $e) {

	echo "There was a problem communicating with SMTP: ".$e->getMessage();
}
and this is the error:

Code: Select all

There was a problem communicating with SMTP: Authentication failed using username 'user' and password '**********'

Posted: Tue Aug 14, 2007 1:21 pm
by Chris Corbyn
You connect to the same server for SMTP and for POP? Is this correct? It's failing to authenticate on that POP3 server for whatever reason.

Posted: Tue Aug 14, 2007 1:27 pm
by evilernie
yep they are both on the same server :/

Posted: Tue Aug 14, 2007 5:04 pm
by Chris Corbyn
Hi,

This won't fix your problem but it may produce something more useful...

http://www.swiftmailer.org/pre-releases ... hp5.tar.gz
http://www.swiftmailer.org/pre-releases ... a-php5.zip

Try one of those, but bear in mind the log API has changed in 3.3.x, and so has the named Swift_Connection_Exception so you'll need to do this instead:

Code: Select all

require_once "/var/www/aamr/swift/Swift.php"; 
require_once "/var/www/aamr/swift/Swift/Connection/SMTP.php"; 
require_once "/var/www/aamr/swift/Swift/Authenticator/\$PopB4Smtp\$.php"; 
try { 

        $log = Swift_LogContainer::getLog();
        $log->setLogLevel(Swift_Log::LOG_EVERYTHING);
        
        $smtp = new Swift_Connection_SMTP("artintheage.com"); 
        $smtp->attachAuthenticator( new Swift_Authenticator_PopB4Smtp("artintheage.com")); 
        $smtp->setUsername("user"); 
        $smtp->setPassword("pass"); 
        
        //Create a Swift instance 
        $swift = new Swift($smtp); 
        
        //Create the sender from the details we've been given 
        $sender = new Swift_Address($email, $name); 
        
        //Create the message to send 
        $message = new Swift_Message("AAMR Comment"); 
        $message->attach(new Swift_Message_Part($body)); 
        
        //Try sending the email 
        $sent = $swift->send($message, "markh@gyroworldwide.com", $sender); 
        
        echo "<pre>" . htmlentities($log->dump(true)) . "</pre>";
        
        //Disconnect from SMTP, we're done 
        $swift->disconnect(); 

} catch (Swift_ConnectionException $e) { 

        echo "There was a problem communicating with SMTP: ".$e->getMessage(); 
}

Posted: Tue Aug 14, 2007 5:19 pm
by evilernie
those links to the pre-releases don't't work :-P

Posted: Tue Aug 14, 2007 6:04 pm
by Chris Corbyn
:oops: Sorry, I accidentally put them outside the web root. Try again :)

Posted: Fri Aug 31, 2007 12:10 pm
by pronto
**New Information**

I, too, use ipowerweb as my isp. Ran up against the exact same problem of a 553 Error.

Then I went to ipowerweb's online helpcenter. Usually the help provided isn't much help there, but in this case it clued me into the real problem.

The message from smtp servers, "553: Sorry, that domain isn't in my list of allowed rcpthosts" is not much help in diagnosing the problem I was having. Here's what ipowerweb said:
This error occurs when a user tries to send mail and the server blocks the mail from being sent. There a number of reasons as to why this occurs and we will discuss a few of them below.

1) iPower email is configured to authenticate using POP rather than SMTP. This means that our server verifies who you are based on the incoming mail server, your username, and password. When you check incoming mail, the server opens a gateway of 20 mins where it will allow you to send your mail out to your intended recipients. Should the 20 minutes pass, the server no longer recognizes who you are and will need to verify security again using the incoming mail server.

The issue starts when email clients (such as Outlook) have an option set to send messages immediately. When you send a message immediately, your email program skips the authentication (verification) process and tries to send without receiving. If this happens after the 20 minute gateway closes, the server gets stuck because it has no idea which user is sending this email. It then stops, and says (not literally), "I do not know you; therefore, I will not let your mail through".

Basically, "553, Sorry, that domain isn't in my list of allowed rcpthosts" means that the server is not recognizing you.

So what are some ways to avoid this? We have two easy methods (A and B) to stop this from happening in Outlook and Outlook Express....
Well they did not address the problem we have with SwiftMail, PHPmailer, and the like. "How do we do a POP befor SMTP," I wondered. Then I found the Swift documentation that adds this step. See the bottom of page http://www.swiftmailer.org/wikidocs/v3/smtpauth for how to do pop before smtp.



-Tony