Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98541 > unrolled thread

Getting response by email reply message

Started byzljubisic@gmail.com
First post2015-11-09 08:12 -0800
Last post2015-11-10 09:37 +1100
Articles 14 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  Getting response by email reply message zljubisic@gmail.com - 2015-11-09 08:12 -0800
    Re: Getting response by email reply message Joel Goldstick <joel.goldstick@gmail.com> - 2015-11-09 11:21 -0500
      Re: Getting response by email reply message zljubisic@gmail.com - 2015-11-09 13:45 -0800
        Re: Getting response by email reply message Laura Creighton <lac@openend.se> - 2015-11-10 06:42 +0100
          Re: Getting response by email reply message zljubisic@gmail.com - 2015-11-09 23:09 -0800
            Re: Getting response by email reply message Laura Creighton <lac@openend.se> - 2015-11-10 11:23 +0100
            Re: Getting response by email reply message Laura Creighton <lac@openend.se> - 2015-11-10 11:37 +0100
    Re: Getting response by email reply message Tim Chase <python.list@tim.thechases.com> - 2015-11-09 12:15 -0600
      Re: Getting response by email reply message zljubisic@gmail.com - 2015-11-09 13:53 -0800
        Re: Getting response by email reply message Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-09 22:14 +0000
        Re: Getting response by email reply message Tim Chase <python.list@tim.thechases.com> - 2015-11-09 16:45 -0600
    Re: Getting response by email reply message Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-09 15:30 -0700
      Re: Getting response by email reply message Marko Rauhamaa <marko@pacujo.net> - 2015-11-10 00:43 +0200
    Re: Getting response by email reply message Chris Angelico <rosuav@gmail.com> - 2015-11-10 09:37 +1100

#98541 — Getting response by email reply message

Fromzljubisic@gmail.com
Date2015-11-09 08:12 -0800
SubjectGetting response by email reply message
Message-ID<79f2c622-e626-43ae-bcec-f85d394ce575@googlegroups.com>
Hi,

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.

I don't know whether email is appropriate for such function.
Maybe better idea would be to have links in email body, one for yes, another for no that will execute something on the server.

Anyway, what are my options?

Regards.

[toc] | [next] | [standalone]


#98543

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2015-11-09 11:21 -0500
Message-ID<mailman.183.1447086069.16136.python-list@python.org>
In reply to#98541
On Mon, Nov 9, 2015 at 11:12 AM, <zljubisic@gmail.com> wrote:

> Hi,
>
> 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.
>
> I don't know whether email is appropriate for such function.
> Maybe better idea would be to have links in email body, one for yes,
> another for no that will execute something on the server.
>
> Anyway, what are my options?
>
> Regards.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I'm assuming this is a website.  If so, why not use a form with a checkbox?

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays

[toc] | [prev] | [next] | [standalone]


#98554

Fromzljubisic@gmail.com
Date2015-11-09 13:45 -0800
Message-ID<83cc2194-ca24-4c44-b5a0-ee6e7b0a8077@googlegroups.com>
In reply to#98543
> I'm assuming this is a website.  If so, why not use a form with a checkbox?

One of ideas is to put two url's in the email, one for yes and the other one for no.

I am also thinking about reading/parsing the reply mail.

Regards.

[toc] | [prev] | [next] | [standalone]


#98574

FromLaura Creighton <lac@openend.se>
Date2015-11-10 06:42 +0100
Message-ID<mailman.197.1447134132.16136.python-list@python.org>
In reply to#98554
In a message of Mon, 09 Nov 2015 13:45:32 -0800, zljubisic@gmail.com writes:
>> I'm assuming this is a website.  If so, why not use a form with a checkbox?
>
>One of ideas is to put two url's in the email, one for yes and the other one for no.
>
>I am also thinking about reading/parsing the reply mail.
>
>Regards.

If what you really need is a voting application, you can look at
https://github.com/mdipierro/evote  which the PSF uses for its elections.

Laura

[toc] | [prev] | [next] | [standalone]


#98578

Fromzljubisic@gmail.com
Date2015-11-09 23:09 -0800
Message-ID<82415229-a6b3-44ff-bae0-0e847dbd9d13@googlegroups.com>
In reply to#98574
> If what you really need is a voting application, you can look at
> https://github.com/mdipierro/evote  which the PSF uses for its elections.

It is not a voting application (I will have more than yes/no answers).
I just want to keep an example simple.

Anyway, I will look into voting application you have suggested in order to see the way how they do it. Thanks.

Regards.

[toc] | [prev] | [next] | [standalone]


#98584

FromLaura Creighton <lac@openend.se>
Date2015-11-10 11:23 +0100
Message-ID<mailman.203.1447151012.16136.python-list@python.org>
In reply to#98578
In a message of Mon, 09 Nov 2015 23:09:50 -0800, zljubisic@gmail.com writes:
>> If what you really need is a voting application, you can look at
>> https://github.com/mdipierro/evote  which the PSF uses for its elections.
>
>It is not a voting application (I will have more than yes/no answers).
>I just want to keep an example simple.
>
>Anyway, I will look into voting application you have suggested in order to see the way how they do it. Thanks.

Their is no demand for 'yes/no answers' -- you can typically vote for
7 people out of 15 candidates for the board, for instance.  But, once
you get to the website you can serve up webpages, using web2py which
presents the voters with a webpage full of whatever you want to render,
including text boxes that let you do arbitrary submissions.

The hard problem being solved here is that only a select list of people
(whom you reach through email) can vote, 
they can do so during some arbitrary period of time (your election period) 
but they do not have to all be on-line at the same time, 
everybody who is legally allowed to vote can change their minds about whom
to vote for and re-submit a vote again, invalidating the earlier one,
and anonymity -- even the election commissioner who holds the election 
does not know who it was that any voter voted for, only that they voted.

And it also keeps track of vote totals.  There are also things to enable
you to present the candidates in different orders for different sets
of voters, as the order in which a list is dished up seems to effect the
outcome, with implications for 'election fairness'.

Thus the whole app is about accountablity.  The tiny web page you serve
up to the people is a tiny bag you bolt into its side. :)  Which makes
the whole thing way, way, way to heavy-weight for most purposes.

However, if accountability is what you need, then it would probably
be easier to adapt the election app to do what you want then to
reinvent all this stuff.

Laura

[toc] | [prev] | [next] | [standalone]


#98586

FromLaura Creighton <lac@openend.se>
Date2015-11-10 11:37 +0100
Message-ID<mailman.205.1447151839.16136.python-list@python.org>
In reply to#98578
In a message of Tue, 10 Nov 2015 11:23:21 +0100, Laura Creighton writes:
>Their is no demand for 'yes/no answers' -- you can typically vote for

s/Their/There/

...

>the whole thing way, way, way to heavy-weight for most purposes.

s/to/too/
also s/heavy-weight/heavyweight/ depending on where in the world you
live, out of scope for this correction.

Sorry about that.  I need more caffeine.

Laura

[toc] | [prev] | [next] | [standalone]


#98548

FromTim Chase <python.list@tim.thechases.com>
Date2015-11-09 12:15 -0600
Message-ID<mailman.185.1447093595.16136.python-list@python.org>
In reply to#98541
On 2015-11-09 08:12, zljubisic@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


[toc] | [prev] | [next] | [standalone]


#98555

Fromzljubisic@gmail.com
Date2015-11-09 13:53 -0800
Message-ID<fccaef52-59bd-4165-a570-2abb6a229dbc@googlegroups.com>
In reply to#98548
> 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

Why should I setup the SMTP server? If my email is on gmail server, I can read the messages from there from time to time.

> 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.

That would be nice but I don't have an access to the server processing scripts.

> 3) write your own STMP daemon that would do listen and react when
> appropriate messages come in.

For now, I could set some time interval, let's say every five minutes for mail checking. I could parse the mail, but at the moment I am not sure how mail body should look like in order to be sure that I have parsed the information correctly.

I agree, #2 is the best approach because you are doing something when the mail arrives. In this case you don't have to pull mail server from time to time.

Regards.

[toc] | [prev] | [next] | [standalone]


#98556

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2015-11-09 22:14 +0000
Message-ID<n1r5su$qit$3@dont-email.me>
In reply to#98555
On Mon, 09 Nov 2015 13:53:24 -0800, zljubisic wrote:

>> 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
> 
> Why should I setup the SMTP server? If my email is on gmail server, I
> can read the messages from there from time to time.

Read more carefully!

The earlier poster suggested options that would work if you set up your 
own server, or already had one.

You can poll your gmail server using pop3 as the earlier reply suggested.

You may need to configure some options in your gmail account to allow 
pop3 access.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#98560

FromTim Chase <python.list@tim.thechases.com>
Date2015-11-09 16:45 -0600
Message-ID<mailman.191.1447110180.16136.python-list@python.org>
In reply to#98555
On 2015-11-09 13:53, zljubisic@gmail.com wrote:
> > 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
> 
> Why should I setup the SMTP server? If my email is on gmail server,
> I can read the messages from there from time to time.

Thus my suggestion "or use the existing one you're receiving this
email at")

Once you have an SMTP+IMAP server like Gmail, you can use
"imaplib" (or "poplib") from the stdlib to log into your Gmail
account, pull down the messages (I presume you identify them somehow,
either by tag, sorting them into a given folder, or something in the
Subject line), and process the message body.

> For now, I could set some time interval, let's say every five
> minutes for mail checking. I could parse the mail, but at the
> moment I am not sure how mail body should look like in order to be
> sure that I have parsed the information correctly.

With imaplib/poplib, you get email.message items back.  You
can .walk() through the mime-tree extracting each part and then
searching it for whatever expression you need to determine whether
the vote was a Yes or No.

Check out the docs on
https://docs.python.org/2/library/email.message.html

-tkc


[toc] | [prev] | [next] | [standalone]


#98557

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-11-09 15:30 -0700
Message-ID<mailman.189.1447108292.16136.python-list@python.org>
In reply to#98541
On Mon, Nov 9, 2015 at 11:15 AM, Tim Chase
<python.list@tim.thechases.com> wrote:
> On 2015-11-09 08:12, zljubisic@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.

[toc] | [prev] | [next] | [standalone]


#98559

FromMarko Rauhamaa <marko@pacujo.net>
Date2015-11-10 00:43 +0200
Message-ID<87k2pqvln6.fsf@elektro.pacujo.net>
In reply to#98557
Ian Kelly <ian.g.kelly@gmail.com>:

> 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.

That's the reason I ended up writing my own SMTP server (in Python3): I
just never could figure out how to configure Postfix to my liking.

For once I appreciated the tons of spam arriving at my mail address. I
didn't have to come up with test material because every few minutes a
fresh spam message came knocking on my door.


Marko

[toc] | [prev] | [next] | [standalone]


#98558

FromChris Angelico <rosuav@gmail.com>
Date2015-11-10 09:37 +1100
Message-ID<mailman.190.1447108662.16136.python-list@python.org>
In reply to#98541
On Tue, Nov 10, 2015 at 9:30 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> 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.

Easiest way to prevent it from forwarding spam is to make it
incoming-only. But yes, you do need to know a bit about how the
internet works; if all you want to do is poll for mail every X
minutes, a POP3 or IMAP connection is far simpler.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web