Re: [Evolution] How to forward a message with a rule ?



On Thu, 2008-09-11 at 13:28 -0400, Reid Thompson wrote:
On Thu, 2008-09-11 at 17:44 +0200, Aconai - Consultant Informatique
wrote:
Thanks, but have you an exemple of a script ?

Regards,

Michel

a ?better? one...mod to your use...

rthompso raker ~/bin $ cat forwardmail.rb
#!/usr/bin/ruby

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($stdin.read)

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

# grab the send date
#
senddate = forwarded_mail.date

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

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

# send the mail
#
Net::SMTP.start( 'your_mail.host.com', 25 ) do|smtpclient|
    smtpclient.send_message(
        forwarded_mail.to_s,
        frommail,
        tomail
    )
end





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