Mail Delivery Report

<%= form_with url: "/search", method: :get do |form| %> <%= form.label :date_from, "From" %> <%= form.date_field :date_from %> <%= form.label :date_to, "To" %> <%= form.date_field :date_to %> <%= form.label :rcpt_to, "To" %> <%= form.email_field :rcpt_to %> <%= form.label :mail_from, "From" %> <%= form.email_field :mail_from %> <%= form.label :status, "Status" %> <%= form.select :status , ['All', 'Sent','SoftFail', 'HardFail','Held'] %> <%= form.submit "search" %> <% end %> <%= link_to "Download Report" ,:action => :export %>
<% if @mails.present? %>
<% @mails.each(:as => :hash ) do |mail| %> <% end %>
Message ID Sender Recipient Subject Date Time Size Status Delivery Details
<%= mail['message_id'] %> <%= mail['mail_from'] %> <%= mail['rcpt_to'] %> <%= mail['subject'] %> <%= Time.at(mail['timestamp']).strftime('%d-%m-%Y') %> <%= Time.at(mail['timestamp']).strftime('%H:%M:%S') %> <%= mail['size'].to_f >= 1048576 ? "#{(mail['size'].to_d/1048576).round(2)} MB" : "#{(mail['size'].to_d/1024).round(2)} KB"%> <%= mail['status'] == "Sent"? "Delivered": mail['status'] %> <%= mail['details'] %>
<% end %>