Hi!

I got so annoyed with the undescriptive subject lines it's learning
alerts ( itslearning.com ) (and my university) uses, that I wrote a
Python script (attached) to take care of this.

-> I added a filter rule to pipe the mail to this script.

It uses an smtp-client in python standard library to send mail to
evolution, and regular expressions to get info from the contents and add
to the subject line.

I can help with tweaking the script, if you find use for it.

Regards,
Mats Taraldsvik

On Tue, 2008-05-20 at 17:22 +0100, andy wrote:
> Reid Thompson wrote: 
> > On Tue, 2008-05-20 at 12:20 +0000, Pete Biggs wrote:
> > 
> >   
> > > Or what about 'redirect'ing the mail to yourself i.e. 
> > > 
> > >   Message -> Forward As -> Redirect
> > > 
> > > Then fill in your own address as the To: and change the subject line to
> > > whatever you want.  This will cause a new message to be created (which
> > > is the only way of doing what you want), but will retain the rest of the
> > > email intact.
> > > 
> > > This would also be a way of dealing with removing attachments.
> > > 
> > > Pete
> > >     
> > 
> > Edit as New Message, Save Draft does create a 'new' message -- it's
> > essentially a copy with modifications.  The Message-id is changed
> > i.e. the message id from your email
> > Message-id: <[EMAIL PROTECTED]>
> > 
> > Edit as New Message, Save Draft
> > 
> > the message id from the Draft
> > Message-id: <[EMAIL PROTECTED]>
> > 
> > and placing both emails in the same folder with threading on, lists the
> > draft as a thread child to your email
> > _______________________________________________
> > Evolution-list mailing list
> > Evolution-list@gnome.org
> > http://mail.gnome.org/mailman/listinfo/evolution-list
> > 
> >   
> Dear Paul, Reid, Patrick & Pete
> 
> First off, thank you very much for all of your replies and
> suggestions. Those are all very much appreciated and there are a
> number of pretty decent workarounds contained therein.
> 
> My wife has seemingly stumbled on a fix that she feels comfortable
> with which is a variation of something already suggested: she will
> merely forward these emails to herself with the subject line she wants
> that will be meaningful to her and delete the original. It's a bit of
> a pain, but I will monitor some of those emails and see if there is
> some way that I can (semi-)automate this process - e.g. when an email
> from Companies House arrives, set a rule to forward it to her email
> address and so it will pop-up waiting for a new subject line.
> 
> Once again, thank you so much from both of us!
> 
> You're a good crowd.
> 
> All the best
> 
> Andy
> 
> -- 
> 
> "If they can get you asking the wrong questions, they don't have to worry 
> about the answers." - Thomas Pynchon, "Gravity's Rainbow"
> _______________________________________________
> Evolution-list mailing list
> Evolution-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/evolution-list
'''
  Copyright (C) 2008 Mats Taraldsvik  <[EMAIL PROTECTED]>
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, see <http://www.gnu.org/licenses/>
'''

#!/usr/bin/python


import sys, re
import smtplib
from email.MIMEText import MIMEText

################## VARIABLES #######

SMTPSERVER = 'smtp.server.com'
SENDERADR = "Name Surname <[EMAIL PROTECTED]>"
TOADR = '[EMAIL PROTECTED]'

###################################

def send_mail (senderadr , destinationadr , subject , contents, server='localhost') :
    mail = MIMEText(contents, _charset="utf-8") # Set right encoding here.
    mail['From'] = senderadr
    mail['Subject'] = subject
    mail['To'] = destinationadr
    smtp = smtplib.SMTP(server)
    smtp.sendmail(senderadr , [ destinationadr ], mail.as_string())
    smtp.close()

message = sys.stdin.readlines() #read the mail that is parsed from stdin

headerflag = False
contentstring = ''
for line in message :
    
    if headerflag :
        contentstring += line.strip('\n')  # Collects content in a string
    if not headerflag :
        if line == '\n' : # If the last item in header list is a newline character, this works
            headerflag = True

#regexp = re.compile(r'From:(.*)[\s\S]Title:(.*)[\s\S]Text:') #Regex to grab text

#if regexp.search(contentstring).groups()[0] and regexp.search(contentstring).groups()[1] :
#    regex_subject = regexp.search(contentstring).groups()[1] + ' [ ' + regexp.search(contentstring).groups()[0] + ' ] '
#else :
regex_subject = "It's Learning ( Message )"

send_mail(SENDERADR, TOADR, regex_subject, contentstring , SMTPSERVER)
_______________________________________________
Evolution-list mailing list
Evolution-list@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-list

Reply via email to