- page_title << @server.name
- page_title << "Messages"
- page_title << "Send"
= render 'servers/sidebar', :active_server => @server
= render 'servers/header', :active_nav => :messages
= render 'header', :active_nav => :new
.pageContent.pageContent--compact
  %p.pageContent__intro.u-margin
    You can use this form to send a message through this mail server. This is useful
    for testing and debugging purposes.
  - if @message.is_a?(OutgoingMessagePrototype)
    %p.pageContent__text.u-margin.newMessageType.newMessageType--outgoing
      <b>You are sending an outgoing message.</b> This e-mail will be routed as if it was an e-mail sent from your mail server.
      = link_to "Simulate an incoming e-mail instead?", {:direction => 'incoming'}, :class => 'u-link'
  - else
    %p.pageContent__text.u-margin.newMessageType.newMessageType--incoming
      <b>You are sending an incoming message.</b> This e-mail will can only be sent to your routes and will behave as if it was received by your mail server.
      = link_to "Simulate an outgoing e-mail instead?", {:direction => 'outgoing'}, :class => 'u-link'
  = form_tag [organization, @server, :messages], :remote => true do
    = hidden_field_tag 'direction', params[:direction]
    .fieldSet
      - if @message.is_a?(OutgoingMessagePrototype)
        .fieldSet__field
          = label_tag :message_from, "From ", :class => 'fieldSet__label'
          .fieldSet__input
            = text_field_tag "message[from]", @message.from, :autofocus => true, :class => 'input input--text'
            %p.fieldSet__text
              Enter the address that you wish to wish to send the message from. This must be
              an address which exists at one of your verified domains.
        .fieldSet__field
          = label_tag :message_to, "To", :class => 'fieldSet__label'
          .fieldSet__input= text_field_tag "message[to]", @message.to, :class => 'input input--text'
      - else
        .fieldSet__field
          = label_tag :message_route_id, "Route", :class => 'fieldSet__label'
          .fieldSet__input= text_field_tag "message[to]", @message.to, :class => 'input input--text'

        .fieldSet__field
          = label_tag :message_from, "From", :class => 'fieldSet__label'
          .fieldSet__input= text_field_tag "message[from]", @message.from, :class => 'input input--text'
      .fieldSet__field
        = label_tag :message_subject, "Subject", :class => 'fieldSet__label'
        .fieldSet__input= text_field_tag "message[subject]", @message.subject, :class => 'input input--text'
      .fieldSet__field
        = label_tag :message_plain_body, "Body", :class => 'fieldSet__label'
        .fieldSet__input= text_area_tag "message[plain_body]", @message.plain_body, :class => 'input input--area'
    .fieldSetSubmit.buttonSet
      = submit_tag "Send Message", :class => 'button button--positive js-form-submit'

