Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'exercise': 0.04; 'url:bitbucket': 0.05; '(b)': 0.07; 'explicit': 0.07; 'already.': 0.09; 'cursor': 0.09; 'template.': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; 'accepting': 0.14; 'default),': 0.16; 'email name:joe': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'here"': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'pane': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject:link': 0.16; 'subject:program': 0.16; 'tab': 0.16; 'url:css': 0.16; 'url:example': 0.16; 'url:subject': 0.16; 'wrote:': 0.18; 'dependent': 0.19; 'subject:page': 0.19; 'starts': 0.20; 'url:view': 0.20; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; '(a)': 0.24; 'cheers,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'external': 0.29; 'leave': 0.29; '(c)': 0.29; 'specified': 0.30; 'invoke': 0.31; 'loads': 0.31; 'question:': 0.31; 'allows': 0.31; 'open': 0.33; 'url:python': 0.33; 'running': 0.33; "i'd": 0.34; 'more,': 0.35; 'but': 0.35; 'there': 0.35; 'received:com.au': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'gmail': 0.38; 'received:211': 0.38; 'url:library': 0.38; 'that,': 0.38; 'short': 0.38; 'does': 0.39; 'morning': 0.39; 'changed': 0.39; 'url:mail': 0.40; 'how': 0.40; 'logged': 0.60; 'field.': 0.61; 'new': 0.61; 'no.': 0.61; 'url:3': 0.61; 'browser': 0.61; 'content-disposition:inline': 0.62; 'address': 0.63; 'god': 0.65; 'yes': 0.68; 'prompt': 0.68; 'subject': 0.69; 'default': 0.69; 'hour': 0.70; 'led': 0.72; 'url:a': 0.72; 'clicking': 0.73; 'browser.': 0.78; 'as:': 0.81; 'compose': 0.84; 'ethan': 0.84; 'exercise,': 0.84; 'furman': 0.84; 'url:fs': 0.84; 'mailto:': 0.91; 'opens': 0.91 Date: Wed, 3 Dec 2014 16:09:45 +1100 From: Cameron Simpson To: Ethan Furman Subject: Re: html page mail link to webmail program MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <5462B94F.4070809@stoneleaf.us> User-Agent: Mutt/1.5.23 (2014-03-12) References: <5462B94F.4070809@stoneleaf.us> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=BdjhjNd2 c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=J0QyKEt1u0cA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=A92cGCtB03wA:10 a=uPZiAMpXAAAA:8 a=1XWaLZrsAAAA:8 a=A1X0JdhQAAAA:8 a=xtERp6CFAAAA:8 a=iC8zilmXAAAA:8 a=gM3_dzWvAAAA:8 a=8AHkEIZyAAAA:8 a=t-IPkPogAAAA:8 a=3U7Yj2bxsH-wUJEHaaIA:9 a=pqCtTzI2NdXAulpG:21 a=6LAJJ5LBYSzBCiP_:21 a=CjuIK1q_8ugA:10 a=_f4kr7sdKmwA:10 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417583397 news.xs4all.nl 2929 [2001:888:2000:d::a6]:35838 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:81835 On 11Nov2014 17:35, Ethan Furman wrote: >Okay, the explicit Python question: Clicking on a mail link in a web browser can start an external program. I would like that external program to be a Python script that: opens a new tab in the currently running browser (or a new default browser window), loads up the default web mail client (or one specified if there is no way to know/have a default), navigates to the compose pane (or starts there if possible), enters in the email address from the link that was passed to it, and, if not too much more, move the cursor to the subject field. > >Surely this can be done in Python. Yes and no. It is dependent on how much control GMail allows you from outside. A quick web search on "open gmail compose using url" led me to this discussion: http://stackoverflow.com/a/8852679 which espouses this URL template: https://mail.google.com/mail/?view=cm&fs=1&to=someone@example.com&su=SUBJECT&body=BODY&bcc=someone.else@example.com which I have tested, and it works. It does require your browser to be logged into GMail already. Given that, you just need a Python script that can be invoked as a standard browser external mail client accepting the mailto: URL from the browser. Decode the URL into to/subject/etc and then open the right URL using the above template. As an exercise, I wrote a short shell script: https://bitbucket.org/cameron_simpson/css/src/tip/bin-cs/gmail which I would invoke from a shell prompt as: gmail -s "subject line here" joe@blogs.com bill@ben.com ... Adapting it to (a) Python (b) accept a mailto:URL and decoding its fields and (c) opening that URL from inside Python using the "webbrowser" module's: https://docs.python.org/3/library/webbrowser.html#module-webbrowser "open" function I leave as an exercise for the reader. Should take less thatn an hour I'd hope. Cheers, Cameron Simpson Perhaps this morning there were only three Euclidean solids, but god changed its mind retroactively at lunchtime, remaking the whole history of the universe. That's the way it is with omnipotent beings. - mikel@Apple.COM (Mikel Evins)