On Mon, Nov 9, 2015 at 11:15 AM, Tim Chase <python.l...@tim.thechases.com> wrote: > On 2015-11-09 08:12, zljubi...@gmail.com wrote: >> I know how to send an email, but I would like to be able to receive >> a reply and act accordingly. Mail reply should contain yes/no >> answer. > > You have a couple options that occur to me: > > 1) set up an SMTP server somewhere (or use the existing one you're > receiving this email at in the event you're getting it as mail > rather than reading it via NNTP or a web interface) to receive the > mail, then create a Python script to poll that inbox (usually POP3 or > IMAP) for messages addressed. The mails can be extracted, parsed, > and deleted > > 2) similar to above, set up an SMTP server, but use server processing > scripts (e.g. procmail scripts) to launch some script when matching > emails are received. It would save you from polling (reducing server > load) and most scripting frameworks pipe the message in on stdin so > you don't have to muck with POP3/IMAP logins. > > 3) write your own STMP daemon that would do listen and react when > appropriate messages come in. > > In most cases, I'd expect that #2 is the easiest/best solution. The > biggest exception being if you have a mail server that doesn't play > well with external tools that expect stdin/stdout processing > (coughexchangecough).
I'd agree with that provided that the SMTP server is already set up somewhere and you're able to to just add a procmail script to it. I wouldn't suggest trying to set up an SMTP server without a strong reason, however. These things are surprisingly tricky to configure so that your server doesn't get used for spam forwarding, and if you don't play nicely with the SMTP community then you'll find your domain and mail server getting added to various blacklists. If you don't already have an SMTP server to use, better IMO to just use hosted email like Gmail or Zoho. The need to poll it may be an inconvenience, but you'll likely avoid some headaches in the long run. -- https://mail.python.org/mailman/listinfo/python-list