blob: 6584bf519505d8e8c89d027a87adda6e46e6c32b (
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
class BaseMailer < ActionMailer::Base
self.mailer_name = "base_mailer"
default to: 'system@test.lindsaar.net',
from: 'jose@test.plataformatec.com',
reply_to: 'mikel@test.lindsaar.net'
def welcome(hash = {})
headers['X-SPAM'] = "Not SPAM"
mail({subject: "The first email on new API!"}.merge!(hash))
end
def welcome_with_headers(hash = {})
headers hash
mail
end
def welcome_from_another_path(path)
mail(template_name: "welcome", template_path: path)
end
def html_only(hash = {})
mail(hash)
end
def plain_text_only(hash = {})
mail(hash)
end
def inline_attachment
attachments.inline['logo.png'] = "\312\213\254\232"
mail
end
def attachment_with_content(hash = {})
attachments['invoice.pdf'] = 'This is test File content'
mail(hash)
end
def attachment_with_hash
attachments['invoice.jpg'] = { data: ::Base64.encode64("\312\213\254\232)b"),
mime_type: "image/x-jpg",
transfer_encoding: "base64" }
mail
end
def attachment_with_hash_default_encoding
attachments['invoice.jpg'] = { data: "\312\213\254\232)b",
mime_type: "image/x-jpg" }
mail
end
def implicit_multipart(hash = {})
attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments)
mail(hash)
end
def implicit_with_locale(hash = {})
mail(hash)
end
def explicit_multipart(hash = {})
attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments)
mail(hash) do |format|
format.text { render text: "TEXT Explicit Multipart" }
format.html { render text: "HTML Explicit Multipart" }
end
end
def explicit_multipart_templates(hash = {})
mail(hash) do |format|
format.html
format.text
end
end
def explicit_multipart_with_any(hash = {})
mail(hash) do |format|
format.any(:text, :html){ render text: "Format with any!" }
end
end
def explicit_multipart_with_options(include_html = false)
mail do |format|
format.text(content_transfer_encoding: "base64"){ render "welcome" }
format.html{ render "welcome" } if include_html
end
end
def explicit_multipart_with_one_template(hash = {})
mail(hash) do |format|
format.html
format.text
end
end
def implicit_different_template(template_name='')
mail(template_name: template_name)
end
def explicit_different_template(template_name='')
mail do |format|
format.text { render template: "#{mailer_name}/#{template_name}" }
format.html { render template: "#{mailer_name}/#{template_name}" }
end
end
def different_layout(layout_name='')
mail do |format|
format.text { render layout: layout_name }
format.html { render layout: layout_name }
end
end
def email_with_translations
mail body: render("email_with_translations", formats: [:html])
end
def without_mail_call
end
def with_nil_as_return_value
mail(:template_name => "welcome")
nil
end
def with_subject_interpolations
mail(subject: default_i18n_subject(rapper_or_impersonator: 'Slim Shady'), body: '')
end
end
|