Page 1 of 1

Gmail smtp and cakephp 1.2 on xampp windows

Posted: Fri Apr 04, 2008 3:06 pm
by lunet3
I am running cakephp 1.2 on XAMPP on Windows XP. I am trying to test SwiftMailer integration with Cake using Gmail

Here is my code

Code: Select all

 
$this->SwiftMailer->connection = 'smtp'; // default and thus you don't have to specify it 
$this->SwiftMailer->smtp_host = 'smtp.gmail.com'; 
$this->SwiftMailer->smtp_type = 'tls'; 
$this->SwiftMailer->smtp_port = '587'; //'587'; //'465';
$this->SwiftMailer->username = 'xxx@gmail.com'; 
$this->SwiftMailer->password = 'xxx';
if($this->SwiftMailer->connect()) 
{ 
$this->SwiftMailer->addTo('from',"xxx@gmail.com","firstname lastname"); 
$this->SwiftMailer->addTo('to',"yyy@gmail.com"); 
$this->SwiftMailer->mailer->addPart("Plain Body"); 
$this->SwiftMailer->mailer->addPart("Html Body", 'text/html'); 
$this->SwiftMailer->send("Subject"); 
} 
}

However, the authenticate() method in SwiftMailer is return this:


Expected response code(s) [250] but got response [530 5.7.0 Must issue a STARTTLS command first. l22sm10679700waf.10]
Log Information
++ Log level changed to 3 << 220 mx.google.com ESMTP l22sm10679700waf.10>> EHLO [127.0.0.1] << 250-mx.google.com at your service, [75.43.217.110]250-SIZE 28311552 250-8BITMIME250-STARTTLS250 ENHANCEDSTATUSCODES>> AUTH CRAM-MD5 >> RSET << 530 5.7.0 Must issue a STARTTLS command first. l22sm10679700waf.10 !! Expected response code(s) [250] but got response [530 5.7.0 Must issue a STARTTLS command first. l22sm10679700waf.10]


How do I start STARTTLS? Is this an XAMPP, Cake, or SwiftMailer issue? I cannot seem to figure it out..

Thanks in advance

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Fri Apr 04, 2008 3:18 pm
by John Cartwright
Please read our forum descriptions before posting.

Moved to Swiftmailer.

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Fri Apr 04, 2008 7:20 pm
by Chris Corbyn
You need to use TLS encryption with port 465.

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 5:11 am
by lunet3
I did enable TLS, however. I still get the message to enable starttls. I am not sure how to solve this. any help is appreciated.

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 5:12 am
by lunet3
i've tried 465 and 587. actually with 465 i got another different error. I think port 587 works better.

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 5:26 am
by Chris Corbyn
lunet3 wrote:i've tried 465 and 587. actually with 465 i got another different error. I think port 587 works better.
587 requires STARTTLS (which Swift v3 does not support), port 465 just requires TLS at connection time. Those are the settings 100% certain on that:

Port = 465
Enc = TLS

What was the other error you got? I'll hazard a guess it a was PHP error due to lack of TLS support in its OpenSSL extension ;)

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 6:28 pm
by lunet3
So Gmail requires STARTTLS on port 587 right? So if swiftmailer does not support STARTTLS, there is no way to use gmail's smtp service?

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 6:31 pm
by lunet3
If i use port 465 with smtp.gmail.com, if($this->SwiftMailer->connect()) simply fails.

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 7:10 pm
by Chris Corbyn
Ah, I'm forgetting this is Swift Mailer version 2. It's so out of date I can't even remember how to get the errors.

... Ok, I just dug deep in my svn repository ....

What does this do after it fails?

Code: Select all

print_r($this->SwiftMailer->getErrors());
You will need to view the source in your browser rather than reading the output as rendered HTML.

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 7:31 pm
by lunet3
I am using SwiftMailer 3.3.3 EasySwift.php, but I plan on switching to just Swift.php once I figure out what is this problem...

Here is the error after I do this command: if($this->SwiftMailer->connect()) using SMTP_TYPE == TLS and SMTP_PORT == 465:

Array
(
[0] => The connection failed to start. An exception was thrown:There was a problem reading line 1 of an SMTP response. The response so far was:[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0) Log Information++ Log level changed to 3
)

Re: Gmail smtp and cakephp 1.2 on xampp windows

Posted: Sat Apr 05, 2008 9:08 pm
by Chris Corbyn
So what that's saying is that Swift was able to establish a connection using the fsockopen() function from PHP, but then it was not able to read from that connection.

If your server is running PHP4 you can't really trust that it really did establish a connection since fsockopen() is pretty buggy with its error reporting in PHP4. It's more than likely either:

a) Your host are blocking the connection with a firewall rule (less likely since you managed on port 587)
b) Your PHP installation does not have TLS support

Unfortunately there's basically nothing I can do since the problem is right down at the server level whether it's a PHP configuration issue or a firewall rule, this is the point where you need to speak to your host ;)