The next step of automating the workflow of the Apache Software Foundation secretarial task went operational today. The current flow now looks like this:
More details on the mail merge described in step 5. It starts with a configuration file. Here’s mine:
require 'rubygems' require 'mail' Mail.defaults do smtp do host 'smtp-server.nc.rr.com' helo 'intertwingly.net' end @from = 'Sam Ruby <secretary@apache.org>' @sig = %{ -- Sam Ruby Secretary, Apache Software Foundation } end
Plus an ERB template file:
to: <%= pubname.inspect %> <<%= email %>> from: <%= from %> cc: secretary@apache.org bcc: <%= bcc %> subject: Your ICLA sent to Apache Secretary Dear <%= pubname %>, This message acknowledges receipt of your ICLA, which has been filed in the Apache Software Foundation records. <%= sig %>
And ultimately, it is processed thus (where vars is an OpenStruct, initially populated with data from HTML forms input and svn properties):
# extract fields from the Mail defaults Mail.defaults do vars.sig = instance_eval {@sig.gsub(/^ +/,'').strip} vars.from = instance_eval {@from} vars.bcc = instance_eval {@bcc} end # expand template message = ERB.new(open(template).read).result(vars.send(:binding)) headers = message.slice!(/\A(\w+: .*\r?\n)*(\r?\n)*/) mail = Mail.new do # apply headers headers.scan(/(\w+):[ \t]*(.*)/).each do |name, value| send name, value unless value.empty? end body message # is this a reply? if vars.email_id in_reply_to vars.email_id references vars.email_id # override subject? if vars.email_subject and !vars.email_subject.empty? subject 're: ' + vars.email_subject end end end # add additional cc if email:addr != email if vars.email_addr and vars.email_addr != vars.email if vars.email_name cc = "#{vars.email_name.inspect} <#{vars.email_addr}>" else cc = vars.email_addr end mail.cc = (mail.cc + [cc]).join(', ') end # ship it! mail.deliver!
s/when operational/went operational/
Feel free to delete this comment.
s/when operational/went operational/
Fixed. Thanks!