Sha256: ca1465b89272beed4e5c958349910cfdfdd1dfbfe6900a13bf5ec8f60117696a
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
#!/usr/bin/env ruby require 'mail' require 'optparse' require 'twmail' OptionParser.new do |opts| banner = <<-HERE #{opts.program_name} is a simple Mail Delivery Agent (MDA) that that exports the parts of the received email as environment variables and calls a shell script that can make use of these variables to further process the mail. USAGE Configure fetchmail to use #{opts.program_name} as MDA: # ~/.fetchmailrc mda #{opts.program_name} HERE opts.banner = banner#.wrap opts.version = TaskWarriorMail::VERSION end.parse! mail = Mail.new(ARGF.read) # Expose mail properties as environment variables %w[date message_id from to subject body].each{|field| value = mail.send(field.to_sym) value = value.join(',') if value.respond_to?(:join) ENV["TWMAIL_#{field.upcase}"] = Shellwords.escape(value.to_s) } # The hook to be executed is read from the environment variable TWMAIL_HOOK # If none is set, this script will assume that twmail_on_new_mail is in the # $PATH and executable. cmd = ENV.fetch("TWMAIL_HOOK", 'twmail-hook') # Call hook script %x[#{cmd}]
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twmail-0.0.6 | bin/twmail-hook |
twmail-0.0.5 | bin/twmail-hook |