[sllug-members]: Google Applications SMTP and PHP

James Noble noblejames at gmail.com
Mon Nov 12 23:56:10 MST 2007


Here is a working file.  Hope it is useful.

<?php
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
require_once "lib/Swift/Authenticator/LOGIN.php";

$conn =& new Swift_Connection_SMTP("smtp.gmail.com",465, SWIFT_SMTP_ENC_TLS);
$conn->setUsername("my_email at google.com");
$conn->setPassword("my_password");
$conn->attachAuthenticator(new Swift_Authenticator_LOGIN());

$swift =& new Swift($conn);
$message =& new Swift_Message("My Sub using delte comments", "My body");

$to =& new Swift_Address("to_someone at somewhere.com", "Jane");
$from =&  new Swift_Address("from_someone at somewhereelse.com","John Doe");

//Now check if Swift actually sends it
if ($swift->send($message, $to, $from)) echo "Sent";
else echo "Failed";

?>


On Nov 12, 2007 6:48 PM, Michael Heath <mike.thomas.heath at gmail.com> wrote:
> The first thing I notice is that, while I'm not familiar with Swift,
> it doesn't seem like you've taken into account that Google SMTP access
> requires STARTTLS/SSL access for SMTP. Thats a start - though, it
> doesn't really explain why the connection would be dropping dead with
> nothing sent, as STARTTLS comes after EHLO.
>
> I'd be really curious on how you get this to work. I hope my random
> comments might help some.
>
> Mike Heath
>
>
> On Nov 12, 2007 6:08 PM, James Noble <noblejames at gmail.com> wrote:
> > I was wondering if anyone has connected a php page to the google
> > applications smtp.  I have tried to do this for a while but have been
> > unable to send the email.  The error I get is
> >
> > Uncaught Error 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) ]
> >
> > $smtp =& new Swift_Connection_SMTP("smtp.gmail.com", 465);
> > $smtp->setUsername("my_username at gmail.com");
> > $smtp->setpassword("my_password");
> >
> > $swift =& new Swift($smtp);
> > $message = "test";
> > if ($swift->send($message, "someone at gmail.com",
> > "someoneelse at gmail.com")) echo "Sent";
> > else echo "Failed";
> >
> > Any help would be appreciated.
> > ______________________________________________________________________
> > See http://www.sllug.org/ for latest SLLUG news, information, links.
> > Join SLLUG and other UT LUG members on irc.FreeNode.net channel #Utah
> > sllug-members at sllug.org
> > http://www.sllug.org/cgi-bin/mailman/listinfo/sllug-members
> >
> ______________________________________________________________________
> See http://www.sllug.org/ for latest SLLUG news, information, links.
> Join SLLUG and other UT LUG members on irc.FreeNode.net channel #Utah
> sllug-members at sllug.org
> http://www.sllug.org/cgi-bin/mailman/listinfo/sllug-members
>


More information about the sllug-members mailing list