This class can be used to process e-mail messages sent to the Dradis server. It uses the ActionMailer module to parse incoming messages that it stores as Note objects in the back-end database.

It also supports attachments (which are parsed as Attachment objects).

An example .procmailrc configuration file could be:

  LOGFILE=procmaillog
  VERBOSE=yes
  GEM_HOME=/usr/local/stow/rubygems/lib/site_ruby/
  RUBYLIB=/usr/local/stow/rubygems/lib/:/usr/local/stow/rubygems/lib/site_ruby/
  RUBY=/usr/bin/ruby
  DRADIS_DIR=/var/data/dradis/dradis-v2.x/server/
  HANDLER='IncomingNoteHandler.receive(STDIN.read)'
  :0 c
  * ^Subject:.*dradis note.*
  | cd $DRADIS_DIR && $RUBY script/runner $HANDLER
Methods
Public Instance methods
receive(email)

This method is invoked by the external MTA that wants to deliver a message to this Dradis instance.

It parses the incoming e-mail message and creates a Note with its contents. If the email contains attachments, they are uploaded as Attachment objects to the corresponding Node.

    # File app/models/incoming_note_handler.rb, line 26
26:   def receive(email)
27:     node = Node.find_or_create_by_label( Configuration.find_by_name('emails_node').value )
28:     category = Category.find_or_create_by_name( 'MagicMailer' )
29:     note = Note.new( :author => 'MagicMailer', :category => category , :node => node )
30: 
31:     note.text = '#[Email Headers]#'
32:     note.text << "\n"
33:     note.text << email.from[0]
34:     note.text << "\n\n"
35:     note.text << '#[Body]#'
36:     note.text << "\n"
37:     note.text << email.body
38: 
39:     note.save
40: 
41:     if email.has_attachments?
42:       email.attachments.each do |attachment|
43:         a = Attachment.new( attachment.original_filename, :node_id => node.id)
44:         a << attachment.read
45:         a.save
46:       end
47:     end
48:   end