Re: [Evolution] Script to search mails

On 8/15/2010 12:32 AM, Thomas Mittelstaedt wrote:

Also, you could define a filter. As action you could choose to call a
program or pipe the mail through a program.

re above, you could take the first part of this filter script and modify it to match and write out data for the emails you want. You might want to switch it from using the tmail package to the mail package.
It would prob end up being around 10 lines long, not counting comments (read in, parse, match, write out)

$ cat forwardmail.rb

require 'rubygems'
require 'tmail'
require 'net/smtp'

# setup to & from
tomail = 'john doe someplace com'
frommail = 'jane done elsewhere com'

# read in mail from pipe
forwarded_mail = TMail::Mail.parse($

# grab the original sender
# strip the domain from original sender address
sender = forwarded_mail.from
idx = sender[0].index('@')

# grab the send date
senddate =

# populate the new header information
# = tomail
forwarded_mail.from = frommail
newsubject = "FW: " + forwarded_mail.subject.to_s
forwarded_mail.subject = newsubject =

# setup the new mail body
forwarded_mail.body = "On #{senddate} #{sender} said \n\n" + forwarded_mail.body

# send the mail
Net::SMTP.start( '', 25 ) do|smtpclient|

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]