[Zope] Re: Cron & Receiving email
Martijn Pieters
mj@digicool.com
Wed, 16 May 2001 19:02:04 +0200
On Wed, May 16, 2001 at 07:48:46AM -0700, Bruce Eckel wrote:
> >Not really. If you can expland on what you'd like to
> accomplish by doing
> >this, maybe I can help a little better.
>
> What I want to do is take the confirmation email that
> PayPal sends and automatically respond to it by emailing
> the product to the customer (trying to do "the simplest
> thing that could possibly work" here).
>
> Another alternative is of course to do it completely
> outside of Zope, and drive the script with cron. That might
> be easiest if
>
> (1) I knew how to "read" mail to a particular address
> inside of Python (it looks like the 'mailbox' module does
> this, but it only reads from one mailbox. Thus, to work, it
> would seem that address must be sent to a particular
> mailbox, which I would guess is possible but requires
> sendmail(?) configuration).
Most MTAs (the software that handles the mail delivery, like sendmail)
allow you to attach a script to an email address. If you control your own
MTA, you can set up an alias in the /etc/aliases file that points not to a
mailbox but to a script. This is how most mailinglists are configured.
This (usually) doesn't require any reconfiguration of the MTA.
The script will get fired up for each email that comes in. You could then
use it to generate your reply email.
If PayPal payments are almost instantanious (only an email delay), you
could have the incoming-mail script handle the parsing of that email and
have it send ZOpe an XML-RPC message to set the correct 'Paid' flag. The
customer would be watching a 'Your payment is being processed' page that
refreshes itself every 30 seconds or so, until the correct flag is set in
the database. He or she can then download the file.
This latter solution is more complex, but allows the selling of files
greater than 100k, as mailboxes of recipients may be quota limited.
> (2) I could figure out how to send attachments with
> Python-generated mail. I know there are libraries, but any
> docs on this seem to go on and on, and have all kinds of
> options and alternatives -- it's so simple in Zope. But in
> python, it appears I would use MimeWriter. I've found two
> examples of this, both of which write to sys.stdout, which
> is confusing -- how do you actually email such a thing?
Use MimeWriter and the sendmail library. And read up on some mime
documentation. You'd need the latter for sending attachments using Zope
as well, as you'll need to create the correct mime boundaries anyway.
Hope this helps!
I-wish-chapter-3-of-TIC++-wasn't-quite-so-long-so-I-can-get-to-the-meat-ly yours,
--
Martijn Pieters
| Software Engineer mailto:mj@digicool.com
| Digital Creations http://www.digicool.com/
| Creators of Zope http://www.zope.org/
---------------------------------------------