Page 1 of 1

Google Apps hosted email questions.

Posted: Mon Jun 11, 2007 5:59 am
by Kamilion
Howdy. Swiftmailer 3.2.6 on PHP5.1/Gentoo.

I've had google apps set up for a while already, believe I signed up early in it's beta.
I also have a gmail account.

Here's the code snippet for my tests:

Code: Select all

<?php
require_once "swiftmailer/Swift.php";
require_once "swiftmailer/Swift/Connection/SMTP.php";

echo "Starting...\n<br>\n<br>\n";

// Create a SMTP connection handler object (Google Apps for your Domain)
$smtp = new Swift_Connection_SMTP("smtp.gmail.com",
Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);
$smtp->setUsername("phpsmtp@sllabs.com");
$smtp->setpassword("areallycleverpassword");

// Create the Swift object interface
$swift =& new Swift($smtp);

// Set up the test email to send
$to = "513d65af-98e3-f2ef-db09-9a112eca5d28@lsl.secondlife.com";
$subject = "Testing my subject";
$message = "A very long\n and drawn out\n message.\n\nRar!";

// Craft the message
$swiftmessage =& new Swift_Message($subject, $message);

// See Swiftmailer. See Swiftmailer mail. Mail, Swiftmailer, mail!
if ($swift->send($swiftmessage, $to, "phpsmtp@sllabs.com"))
{ echo "Sent"; } else { echo "Failed"; }

?>
It works just fine as is, but I've got a question on proper configuration:

Google Apps is set up to use aspmx.l.google.com. Should I be using this for my SMTP server, or stick with smtp.gmail.com/smtp.googlemail.com?

d11wtq, thanks so much for spending so much time and effort on this; hopefully when I can get my hands on some cash I can send you a couple bucks for your trip. Oh, and awesome docs; just one thing -- I had to page through several pages before I was able to patch this together, any chance of a simple named wiki page with GMail/Apps direct instructions, as this seems to be a very popular use of Swiftmailer?

Cheers!

Posted: Mon Jun 11, 2007 6:18 am
by Chris Corbyn
I'm the first to admit my documentation is not well laid out. Heck, even I have a hard time finding where I documented some things if I've not worked on that page for a while. I have the basis of a new documentation module integrated directly into the website but this has been idle (in development) for a month or two now.

I've never looked with Google Apps before but from Swift's point of view, it will just connect to any server you tell it to if it can do so. If Google Apps tell you to use aspmx.l.google.com then I'd use that yes :)

Posted: Mon Jun 11, 2007 6:28 am
by Kamilion
Holy smokes, do you sleep at your computer?

I don't think I've ever gotten a faster forum response -- In the time you took to respond, I paged through the forums.

Your support is pure awesomeness. It's a rare day when I'll see anything close to this kind of support for anything else. I'll be proud to donate once my bank account reaches a balance of more than $0.00 ;)

Anyway, thanks for the reply, I'll see if aspmx.l.google.com works or breaks.



<--- Swiftmailer convert until PHP6 breaks something
I think I'm gonna use this in every project I need email on.
Already been crowing about it on the SLDev mailing list for Second Life.
Here's to a long life to Swiftmailer; *Slides a lager down the bar to ya*

Posted: Mon Jun 11, 2007 6:41 am
by Chris Corbyn
Heh thanks :) When PHP6 comes out and "breaks" something I'll be straight on it. In fact, I'm already regularly checking out the latest snapshots once every months or two just to see if there are any features I can take advantage of. I can't wait for the day PHP4 development is discontinued since the OO'ness in Swift makes me jump through hoops in PHP4 :evil:

Posted: Fri Jun 15, 2007 12:55 am
by Kamilion
Okay, I've got it all implemented and working; but now I've got a little bit of a problem with swiftmailer.

It looks like every mail I send out has an extra space character at the end, 0x20.
How do I get rid of this?

I'm using swiftmailer to send mail to a script hosted on another platform, and that extra space is throwing everything off in it's parser.

Where should I be looking in the code to remove this obstacle?

Also, is there any way to turn word wrap off? Since it's going to a script, I don't need the word wrap screwing up long command lines...

I've already attempted to work around these flaws in the client script, but I'd really rather not have to add special case scenarios just for swiftmailer...

Posted: Fri Jun 15, 2007 4:54 am
by Chris Corbyn
Swift shouldn't be adding any space to the content. Are you sure it's not being added by an intermediate server which is relaying the mail? You can double-check by outputting the message before Swift sends it.

Code: Select all

$stream =& $message->build();
echo "**START**" . $stream->readFull() . "**END**";

Posted: Sun Jul 15, 2007 9:11 am
by anjanesh
Its mentioned in wiki, that
however, they do impose a maximum limit of 50 emails in any one go.
Is this the same for Google Apps ? ...Since the SMTP server is still smtp.gmail.com.

Posted: Sun Jul 15, 2007 10:20 am
by Chris Corbyn
anjanesh wrote:Its mentioned in wiki, that
however, they do impose a maximum limit of 50 emails in any one go.
Is this the same for Google Apps ? ...Since the SMTP server is still smtp.gmail.com.
I'm not 100%, but I'd guess so. That's something that would need to be directed to gmail support ;)