from_email: the email part of the From: line, or nil if empty
Return value:
A string (multi-line ok) containing the text of the signature, or nil to
- use the default signature.
+ use the default signature, or :none for no signature.
EOS
HookManager.register "before-edit", <<EOS
m = RMail::Message.new
m.header["Content-Type"] = "text/plain; charset=#{$encoding}"
m.body = @body.join("\n")
- m.body = m.body
m.body += sig_lines.join("\n") unless $config[:edit_signature]
+ ## body must end in a newline or GPG signatures will be WRONG!
+ m.body += "\n" unless m.body =~ /\n\Z/
## there are attachments, so wrap body in an attachment of its own
unless @attachments.empty?
## do whatever crypto transformation is necessary
if @crypto_selector && @crypto_selector.val != :none
from_email = PersonManager.person_for(@header["From"]).email
- to_email = (@header["To"] + @header["Cc"] + @header["Bcc"]).map { |p| PersonManager.person_for(p).email }
+ to_email = [@header["To"], @header["Cc"], @header["Bcc"]].flatten.compact.map { |p| PersonManager.person_for(p).email }
m = CryptoManager.send @crypto_selector.val, from_email, to_email, m
end
if text
@header[field] = parse_header field, text
update
- field
end
else
- default =
- case field
+ default = case field
when *MULTI_HEADERS
+ @header[field] ||= []
@header[field].join(", ")
else
@header[field]
text = contacts.map { |s| s.longname }.join(", ")
@header[field] = parse_header field, text
update
- field
end
end
end
## first run the hook
hook_sig = HookManager.run "signature", :header => @header, :from_email => from_email
+
+ return [] if hook_sig == :none
return ["", "-- "] + hook_sig.split("\n") if hook_sig
## no hook, do default signature generation based on config.yaml