aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/templates/rails/mailers/email.html.erb
blob: cf95cd8ad079748de26cc9f1c6d9839897b9e7e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width" />
<style type="text/css">
  html, body, iframe {
    height: 100%;
  }

  body {
    margin: 0;
  }

  header {
    width: 100%;
    padding: 10px 0 0 0;
    margin: 0;
    background: white;
    font: 12px "Lucida Grande", sans-serif;
    border-bottom: 1px solid #dedede;
    overflow: hidden;
  }

  dl {
    margin: 0 0 10px 0;
    padding: 0;
  }

  dt {
    width: 80px;
    padding: 1px;
    float: left;
    clear: left;
    text-align: right;
    color: #7f7f7f;
  }

  dd {
    margin-left: 90px; /* 80px + 10px */
    padding: 1px;
  }

  dd:empty:before {
    content: "\00a0"; // &nbsp;
  }

  iframe {
    border: 0;
    width: 100%;
  }
</style>
</head>

<body>
<header>
  <dl>
    <% if @email.respond_to?(:smtp_envelope_from) && Array(@email.from) != Array(@email.smtp_envelope_from) %>
      <dt>SMTP-From:</dt>
      <dd><%= @email.smtp_envelope_from %></dd>
    <% end %>

    <% if @email.respond_to?(:smtp_envelope_to) && @email.to != @email.smtp_envelope_to %>
      <dt>SMTP-To:</dt>
      <dd><%= @email.smtp_envelope_to %></dd>
    <% end %>

    <dt>From:</dt>
    <dd><%= @email.header['from'] %></dd>

    <% if @email.reply_to %>
      <dt>Reply-To:</dt>
      <dd><%= @email.header['reply-to'] %></dd>
    <% end %>

    <dt>To:</dt>
    <dd><%= @email.header['to'] %></dd>

    <% if @email.cc %>
      <dt>CC:</dt>
      <dd><%= @email.header['cc'] %></dd>
    <% end %>

    <dt>Date:</dt>
    <dd><%= Time.current.rfc2822 %></dd>

    <dt>Subject:</dt>
    <dd><strong><%= @email.subject %></strong></dd>

    <% unless @email.attachments.nil? || @email.attachments.empty? %>
      <dt>Attachments:</dt>
      <dd>
        <%= @email.attachments.map { |a| a.respond_to?(:original_filename) ? a.original_filename : a.filename }.join(', ') %>
      </dd>
    <% end %>

    <% if @email.multipart? %>
      <dd>
        <select onchange="document.getElementsByName('messageBody')[0].src=this.options[this.selectedIndex].value;">
          <option <%= request.format == Mime::Type[:HTML] ? 'selected' : '' %> value="?part=text%2Fhtml">View as HTML email</option>
          <option <%= request.format == Mime::Type[:TEXT] ? 'selected' : '' %> value="?part=text%2Fplain">View as plain-text email</option>
        </select>
      </dd>
    <% end %>
  </dl>
</header>

<% if @part && @part.mime_type %>
  <iframe seamless name="messageBody" src="?part=<%= Rack::Utils.escape(@part.mime_type) %>"></iframe>
<% else %>
  <p>
    You are trying to preview an email that does not have any content.
    This is probably because the <em>mail</em> method has not been called in <em><%= @preview.preview_name %>#<%= @email_action %></em>.
  </p>
<% end %>

</body>
</html>