Getting response by email reply message

Tim Chase python.list at tim.thechases.com
Mon Nov 9 13:15:29 EST 2015


On 2015-11-09 08:12, zljubisic at 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).

-tkc






More information about the Python-list mailing list