Page 1 of 1

Connecting to SMTP Gmail

Posted: Fri Nov 09, 2007 2:59 pm
by Azeem
I have been trying to send mail via gmail smtp but not able to do so server is on php4


and the code i used i s

Code: Select all

<?php

require('/var/www/site0/lib/Swift/lib/Swift.php');
require('/var/www/site0/lib/Swift/lib/Swift/Connection/SMTP.php');
require('/var/www/site0/lib/Swift/lib/Swift/Authenticator/LOGIN.php');

$smtp =&new Swift_Connection_SMTP("smtp.gmail.com",465, SWIFT_SMTP_PORT_SECURE,SWIFT_SMTP_ENC_TLS);

$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());
$smtp->setUsername("myusername@gmail.com");
$smtp->setpassword("mypass");


$mail = &new Swift($smtp);


if (!$mail->send(
   '"Azeem" <azimyasin@gmail.com>',
   'Some subject',
   'The body')) echo 'Not sent!';

?>


The error i get is

root# php sendcheck.php
PHP Fatal error: <br /><strong>Uncaught Error</strong> of type [swift_connectionexception] with message [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) ]
@0 swift::swift() in /var/www/site0/src/noticeboard/sendcheck.php on line 14
@1 swift::connect() in /var/www/site0/lib/Swift/lib/Swift.php on line 109
@2 swift::command() in /var/www/site0/lib/Swift/lib/Swift.php on line 227

in /var/www/site0/lib/Swift/lib/Swift/Errors.php on line 99

I would be very thank ful if any one could help me sort it out
p.s. the username and pass i use are correct

Waiting

Posted: Sun Nov 11, 2007 4:48 am
by Azeem
Still waiting to get a reply

Posted: Sun Nov 11, 2007 5:27 am
by choubix
not sure that" still waiting to get a reply" is a seller as it's not microsoft's hotline here... ;)

Is the syntax of the "send" correct?
here I use:

$swift->send($message, "receveir@email.com", "sender@email.com");

and the port 465: I think it is not necessary to declare it.
for the syntax on php4 you can check:

http://www.swiftmailer.org/wikidocs/v3/connections/smtp

+++

Posted: Sun Nov 11, 2007 8:12 am
by Azeem
Dude i did checked it out.

and as far as syntax its fine i guess.

Posted: Sun Nov 11, 2007 10:34 am
by choubix
and setPassword instead of setpassword?
(not sure swift is sensitive to the case)

Posted: Mon Nov 12, 2007 1:06 pm
by Azeem
Nops no luck tried that as well.

Posted: Mon Nov 12, 2007 2:15 pm
by chuckl
From your example:

Code: Select all

$smtp =&new Swift_Connection_SMTP("smtp.gmail.com",465, SWIFT_SMTP_PORT_SECURE,SWIFT_SMTP_ENC_TLS);
from the examples in the docs

Code: Select all

$smtp= &new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS));
Notice the '465,' anywhere in the example?

Posted: Tue Nov 13, 2007 6:56 am
by Azeem
Worked.

Thanks.. :)