HELP!!! Google Apps and Swift

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
silentszeto
Forum Newbie
Posts: 3
Joined: Tue Sep 07, 2004 8:24 am

HELP!!! Google Apps and Swift

Post by silentszeto »

Hi,
I am pretty new to PHP.... and I am running this script locally (from my comp)...
i can't SOLVE the problems i have with this simple script...
I am running this with PHP5
My host is iPower and i use google apps (gmail) to do my emails.
User/Password are edited out

Code: Select all

 
<?
//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
 $swift = new Swift(new Swift_Connection_SMTP(
    "smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE /*Swift_Connection_SMTP::ENC_TLS*/));
$smtp->setUsername("MYUSER");
$smtp->setpassword("********"); 
$swift = new Swift($smtp);
$message =& new Swift_Message("My subject", "My body");
 
$sent = $swift->send($message, "me@me.com", "myuser@mydomain.com");
echo "Sent to $sent recipients";
?>
 
 
If i dun comment out the /*Swift_connectino_SMTP::ENC_TLS, i get :
Fatal error: Call to a member function setUsername() on a non-object in C:\AppServ\www\swift\test.php on line 7
if i comment out that... i get a much bigger mess...
Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'There was a problem reading line 1 of an SMTP response. The response so far was:<br />[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0) ' in C:\AppServ\www\swift\lib\Swift\Connection\SMTP.php:250 Stack trace: #0 C:\AppServ\www\swift\lib\Swift.php(306): Swift_Connection_SMTP->read() #1 C:\AppServ\www\swift\lib\Swift.php(217): Swift->command('', 220) #2 C:\AppServ\www\swift\lib\Swift.php(101): Swift->connect() #3 C:\AppServ\www\swift\test.php(6): Swift->__construct(Object(Swift_Connection_SMTP)) #4 {main} thrown in C:\AppServ\www\swift\lib\Swift\Connection\SMTP.php on line 250
Anyone know why???
I tried running on my hosting server (with PHP4)... which is worse... nothing showed.. everything disappeared= not working...
eggnogg
Forum Newbie
Posts: 11
Joined: Wed Feb 15, 2006 7:31 pm

Re: HELP!!! Google Apps and Swift

Post by eggnogg »

im not sure, and if you have fixed your code. i am tangled myself now. the only thing i'd see and change is

$swift = new Swift(ne....

put that in the $smtp, like so

$smtp =& new Swift_Connection_SMTP("smtp.gmail.com", 465);
$smtp->setUsername("...");
$smtp->setpassword("...");

$swift =& new Swift($smtp);


idk, just throwing out possibilities
im also tangled with using this cool mailer

its not very straight forwarding, if you not a php cleric, but still tryin

edit: also, maybe you should add numbers, like th 465 i got up there, and the enc type which im still trying to find how to use
eggnogg
Forum Newbie
Posts: 11
Joined: Wed Feb 15, 2006 7:31 pm

Re: HELP!!! Google Apps and Swift

Post by eggnogg »

$smtp =& new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);

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

Re: HELP!!! Google Apps and Swift

Post by Chris Corbyn »

Yes, so the problem was that you were trying to make method calls to an object that didn't exist ($smtp). Also, you were creating two instances of the Swift class, rather than one of the SMTP class, then one of the Swift class.

Good to hear you have figured it out now anyway :)
Post Reply