views:

213

answers:

4

When a user completes an order at my online store, he gets an email confirmation.

Currently we're sending this email via Gmail (which we chose over sendmail for greater portability) after we authorize the user's credit card and before we show him a confirmation message (i.e., synchronously).

It's working fine in development, but I'm wondering if this will cause a problem in production. Will it require making the user wait too long? Will many simultaneous Gmail connections get us in trouble? Any other general caveats?

If sending the emails synchronously will be a problem, could someone recommend an asynchronous solution (is ar_mailer any good?)

+2  A: 

The main issue I can think of is that Gmail limits the amount of email you can send daily, so if you get too many orders a day it might break.

As they say :

"In an effort to fight spam and prevent abuse, Google will temporarily disable your account if you send a message to more than 500 recipients or if you send a large number of undeliverable messages. If you use a POP or IMAP client (Microsoft Outlook or Apple Mail, e.g.), you may only send a message to 100 people at a time. Your account should be re-enabled within 24 hours. "

http://mail.google.com/support/bin/answer.py?hl=en&answer=22839

I would recommend using sendmail on your server in order to have greater control over what's going on and don't depend on another service, especially when sendmail is not really complicated to set up.

marcgg
That's really good information to have.
David Berger
Well, as long as the order confirmations are only going out to the customer, there shouldn't be a problem. I can't think of any situation in which you'd need to send an order confirmation to 500+ people.
Calvin
Yeah, I agree with @Calvin -- these limitations don't seem to apply to my situation.
Horace Loeb
Also I have to agree with David Berger, GMail does crash.We had exactly the same dilema in my compagny and we didn't took the risk of loosing control of such an important part of the ordering process and we used sendmail.
marcgg
+1  A: 

The internet is not as resilient as some people would have you believe, the link between you and GMail will break at some point or GMail will go offline causing the user to think that they have not paid sucessfully.

I would put some other queue in place, sendmail sounds acceptable and you can't create your site now for where it 'might' be hosted in the future.

Ryan

Ryan ONeill
+1  A: 

If the server waits for the email to be sent before giving the user any feedback, were there problems connecting to the mailserver (timeouts, server down etc) the user request would timeout too and he wouldn't be told anything about the status of his order, so I believe you should really do this asynchronously. Also, you should check whether doing that is even allowed by GMail's TOS. If that's not the case, you may check if that's allowed if you purchase one of their subscriptions. Also, there's surely a limit to the number of outgoing emails you may send within a given timeframe so if you're expecting your online store to be successful, you may hit that limit and bump into some nasty issue. If you're not self-hosting the site, you should check whether your host offers email servers (several plans include them for free) as then using your host's ISP would be the most obvious choice.

emaster70
+1  A: 

FACT: Gmail crashes. Not often, but it happens, and you can't control it or test it.

The simplest quick-fix is to start a separate thread or fork a subprocess to send the email. Yes, there likely will arise problems from using Gmail, and I really have no input on that vs. the alternatives. But from a design perspective, there's just no reason to make the user wait for that process to complete.

From a testing perspective, this might be where a proxy pattern might come in handy. It might be easy for you to directly invoke Gmail to send a message. Make it harder. Put in a proxy object that does the mailing for you that you can turn off (because heaven knows you can't for testing purposes make Gmail crash). Just make your team follow what happens in the event of an email malfunction by turning off the proxy and trying to complete an order. If you are doing it synchronously, then all the plagues mentioned here by other posters will rear their heads. If you are doing it asynchronously, you should be able to allow it to fail silently (from the user's perspective--from your perspective there should be enormous logging statements and text messages in the middle of the night and possibly a mild electric current arcing across the surface of someone's skin).

David Berger