Skip to content

Instantly share code, notes, and snippets.

@andyl
Created August 22, 2013 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyl/6312337 to your computer and use it in GitHub Desktop.
Save andyl/6312337 to your computer and use it in GitHub Desktop.
<meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
<% if mail.subject %>
<title><%= h mail.subject %></title>
<% end %>
<style type="text/css">
.message_headers {
width: 100%;
padding: 10px 0 0 0;
margin: 0;
background: #fff;
font-size: 12px;
font-family: "Lucida Grande";
border-bottom: 1px solid #dedede;
overflow: auto;
}
.message_headers dl {
float: left;
width: 75%;
margin: 0 0 10px 0;
padding: 0;
}
.message_headers dt {
width: 92px;
padding: 1px;
margin: 0;
float: left;
text-align: right;
font-weight: bold;
color: #7f7f7f;
}
.message_headers dd {
width: 100%;
margin: 0 0 0 102px;
padding: 1px;
}
.message_headers p.alternate {
float: right;
margin: 0;
}
.message_headers p.alternate a {
color: #09c;
}
pre.message_body {
padding: 10px;
word-wrap: break-word;
}
.message_banner {
background: lightblue;
text-align: center;
border: 1px solid black;
margin-bottom: 5px;
font-size: 10px;
padding: 2px;
}
input { width: 100% }
textarea {
margin-top: 10px;
margin-bottom: 5px;
width: 100%;
height: 100px;
}
</style>
<div id="message_display">
<div class="message_headers">
<dl>
<dt>From:</dt>
<dd><%= h from %></dd>
<% unless sender.empty? %>
<dt>Sender:</dt>
<dd><%= h sender %></dd>
<% end %>
<% unless reply_to.empty? %>
<dt>Reply-To:</dt>
<dd><%= h reply_to %></dd>
<% end %>
<% if mail.subject %>
<dt>Subject:</dt>
<dd><strong><%= h mail.subject %></strong></dd>
<% end %>
<dt>Date:</dt>
<dd><%= Time.now.strftime("%b %e, %Y %I:%M:%S %p %Z") %></dd>
<% unless to.empty? %>
<dt>To:</dt>
<dd><%= h to %></dd>
<% end %>
<% unless cc.empty? %>
<dt>CC:</dt>
<dd><%= h cc %></dd>
<% end %>
<% unless bcc.empty? %>
<dt>BCC:</dt>
<dd><%= h bcc %></dd>
<% end %>
<% if @attachments.any? %>
<dt>Attachments:</dt>
<dd>
<% @attachments.each do |filename, path| %>
<a href="<%= path %>"><%= filename %></a>&nbsp;
<% end %>
</dd>
<% end %>
</dl>
<% if mail.multipart? %>
<p class="alternate">
<% if type == "plain" && mail.html_part %>
<a href="rich.html">View HTML version</a>
<% elsif type == "rich" && mail.text_part %>
<a href="plain.html">View plain text version</a>
<% end %>
</p>
<% end %>
</div>
<% if type == "plain" %>
<pre class="message_body"><%= auto_link(h(body)) %></pre>
<% else %>
<%= body %>
<% end %>
</div>
<div id="message_reply">
<div class="message_banner">REPLY</div>
<form action="http://<%= from.split('@').last %>:3000/letter_opener_reply" method="POST">
<div class="message_headers">
<dl>
<dt>From:</dt>
<dd><input type='text' name='from' value='<%= h to %>'/></dd>
<% unless reply_to.empty? %>
<dt>In-Reply-To:</dt>
<dd><input type='text' name='In-Reply-To' value='<%= h reply_to %>'/></dd>
<% end %>
<dt>Subject:</dt>
<dd><input type='text' name='subject' value='Re: <%= h mail.subject %>'/></dd>
<dt>To:</dt>
<dd><input type='text' name='to' value='<%= h from %>'/></dd>
<dt>CC:</dt>
<dd><input type="text" name="cc"/></dd>
<dt>BCC:</dt>
<dd><input type="text" name="bcc"/></dd>
</dl>
</div>
<textarea name="text"></textarea>
<input type="submit" value="Submit form data via HTTP POST to http://<%= from.split('@').last %>:3000/letter_opener_reply"></input>
</form>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment