Events

MidiSmtpServer can be easily customized via subclassing. Simply subclass the MidiSmtpServer class as given in the example and re-define some of the event handlers.


on_logging_event

  # event on LOGGING
  # the exposed logger property is from class MidiSmtpServer::ForwardingLogger
  # and pushes any logging message to this on_logging_event.
  # if logging occurs from inside session, the _ctx should be not nil
  # if logging occurs from an error, the err object should be filled
  def on_logging_event(ctx, severity, msg, err: nil)
  end


on_connect_event

  # event on CONNECTION
  # you may change the ctx[:server][:local_response] and
  # you may change the ctx[:server][:helo_response] in here so
  # that these will be used as local welcome and greeting strings
  # the values are not allowed to return CR nor LF chars and will be stripped
  def on_connect_event(ctx)
  end


on_disconnect_event

  # event before DISCONNECT
  def on_disconnect_event(ctx)
  end


on_proxy_event

    # event on PROXY
    # you may raise an exception if you want to block some addresses
    # you also may change or add any value of the hash:
    # {proto, source_ip, source_host, source_port, dest_ip, dest_host, dest_port}
    # a returned value hash is set as ctx[:server][:proxy]
  def on_proxy_event(ctx, proxy_data) end


on_helo_event

  # event on HELO/EHLO
  # you may change the ctx[:server][:helo_response] in here so
  # that this will be used as greeting string
  # the value is not allowed to return CR nor LF chars and will be stripped
  def on_helo_event(ctx, helo_data)
  end


on_mail_from_event

  # get address send in MAIL FROM
  # if any value returned, that will be used for ongoing processing
  # otherwise the original value will be used
  def on_mail_from_event(ctx, mail_from_data)
  end


on_rcpt_to_event

  # get each address send in RCPT TO
  # if any value returned, that will be used for ongoing processing
  # otherwise the original value will be used
  def on_rcpt_to_event(ctx, rcpt_to_data)
  end


on_message_data_start_event

  # event when beginning with message DATA
  def on_message_data_start_event(ctx)
  end


on_message_data_receiving_event

  # event while receiving message DATA
  def on_message_data_receiving_event(ctx)
  end


on_message_data_headers_event

  # event when headers are received while receiving message DATA
  def on_message_data_headers_event(ctx)
  end


on_message_data_event

  # get each message after DATA <message>
  def on_message_data_event(ctx)
  end


on_process_line_unknown_event

  # event when process_line identifies an unknown command line
  # allows to abort sessions for a series of unknown activities to
  # prevent denial of service attacks etc.
  def on_process_line_unknown_event(ctx, line)
  end