dcidev_mailer 0.0.1 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +40 -1
- data/lib/dcidev_mailer/mail.rb +48 -0
- metadata +3 -3
- data/lib/dcidev_mailer/rails.rb +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63527600458fafe442b04ad42cc9afe6ce814587d6c7d3ca1df0a9c8ee2cfbf3
|
|
4
|
+
data.tar.gz: 134af01794ea7b23d6075959f87b09e6952362059ddec4f3f5b64dabdd690771
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2359b8a5f941a4b2ee802386b2b27c8e1167a7543d7fadfd3615826368601c8e6e36a0f39264c180ff01e548f04b0582fd3852843ba3e134d5f641203f142a81
|
|
7
|
+
data.tar.gz: b29ffd3b8554b5cd8767edff42e5cea95fc11c14f0e684f30957f8743c05019957954a01f3b9a994c35561a5782bbb8f06907c41bacd7bd7354228bad1bec791
|
data/README.md
CHANGED
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
ENV :
|
|
3
|
+
```
|
|
4
|
+
DEFAULT_EMAIL_SENDER
|
|
5
|
+
USE_MANDRILL_MAILER
|
|
6
|
+
[EMAIL_PROVIDER]_SMTP_ADDRESS
|
|
7
|
+
[EMAIL_PROVIDER]_SMTP_DOMAIN
|
|
8
|
+
[EMAIL_PROVIDER]_SMTP_PASSWORD
|
|
9
|
+
[EMAIL_PROVIDER]_SMTP_USERNAME
|
|
10
|
+
[EMAIL_PROVIDER]_SMTP_PORT
|
|
11
|
+
[EMAIL_PROVIDER]_SMTP_AUTO_TLS
|
|
12
|
+
[EMAIL_PROVIDER]_SMTP_TLS
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
mandril
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
response = ::DcidevMailer::Mandrill.send_email(
|
|
19
|
+
subject: email_template.subject,
|
|
20
|
+
html_body: email_template.wording,
|
|
21
|
+
header_url: email_template.header.try(:url),
|
|
22
|
+
footer_url: email_template.footer.try(:url),
|
|
23
|
+
to: customer.email,
|
|
24
|
+
# from: "from@gmail.com",
|
|
25
|
+
attachments: attachments,
|
|
26
|
+
email_template_path: "cimb_mailer/email.html.erb"
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
action mailer
|
|
31
|
+
```
|
|
32
|
+
DcidevMailer::Rails.email(
|
|
33
|
+
html_body: template.wording,
|
|
34
|
+
header_url: template.header.try(:url),
|
|
35
|
+
footer_url: template.footer.try(:url),
|
|
36
|
+
file_attachments: file_attachments,
|
|
37
|
+
to: customer.email,
|
|
38
|
+
subject: template.subject
|
|
39
|
+
)
|
|
40
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# require 'mail'
|
|
4
|
+
require 'action_mailer/base'
|
|
5
|
+
require 'action_view'
|
|
6
|
+
require 'mail'
|
|
7
|
+
module DcidevMailer
|
|
8
|
+
class Mail < ActionMailer::Base
|
|
9
|
+
default from: ENV['DEFAULT_EMAIL_SENDER']
|
|
10
|
+
class << self
|
|
11
|
+
|
|
12
|
+
def email(html_body: "", header_url: "", footer_url: "", file_attachments: nil, to: "", from: nil, subject: "", template_path: "", template_name: "")
|
|
13
|
+
wording, images = DcidevMailer.format_image_from_html(html_body)
|
|
14
|
+
|
|
15
|
+
@wording = "wording"
|
|
16
|
+
locals = { wording: wording, header: nil, footer: nil }
|
|
17
|
+
locals, images = DcidevMailer.format_header_footer(header_url: header_url, footer_url: footer_url, locals: locals, images: images) if header_url.present? && footer_url.present?
|
|
18
|
+
|
|
19
|
+
att = ActionMailer::Base.new
|
|
20
|
+
if file_attachments.present?
|
|
21
|
+
file_attachments.each do |a|
|
|
22
|
+
att.attachments[a[:name].to_s] = a[:content] unless a[:content].nil?
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# self.attachments.inline['header'] = File.read(Utility.download_to_file(header_url)) rescue nil if header_url.present?
|
|
27
|
+
# self.attachments.inline['footer'] = File.read(Utility.download_to_file(footer_url)) rescue nil if footer_url.present?
|
|
28
|
+
|
|
29
|
+
att.attachments.inline['header'] = File.read(Utility.download_to_file(header_url)) rescue nil if header_url.present?
|
|
30
|
+
att.attachments.inline['footer'] = File.read(Utility.download_to_file(footer_url)) rescue nil if footer_url.present?
|
|
31
|
+
|
|
32
|
+
ActionMailer::Base.mail(
|
|
33
|
+
to: to,
|
|
34
|
+
subject: subject,
|
|
35
|
+
format: "text/html",
|
|
36
|
+
from: from,
|
|
37
|
+
template_path: template_path,
|
|
38
|
+
template_name: template_name
|
|
39
|
+
) do |format|
|
|
40
|
+
format.html {
|
|
41
|
+
ActionView::Base.new.render locals: locals
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dcidev_mailer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Punto Damar P
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-01-
|
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mimemagic
|
|
@@ -47,8 +47,8 @@ extra_rdoc_files: []
|
|
|
47
47
|
files:
|
|
48
48
|
- README.md
|
|
49
49
|
- lib/dcidev_mailer.rb
|
|
50
|
+
- lib/dcidev_mailer/mail.rb
|
|
50
51
|
- lib/dcidev_mailer/mandrill.rb
|
|
51
|
-
- lib/dcidev_mailer/rails.rb
|
|
52
52
|
homepage:
|
|
53
53
|
licenses: []
|
|
54
54
|
metadata: {}
|
data/lib/dcidev_mailer/rails.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'mail'
|
|
2
|
-
|
|
3
|
-
module DcidevMailer
|
|
4
|
-
class Rails < ApplicationMailer
|
|
5
|
-
default from: ENV['DEFAULT_EMAIL_SENDER']
|
|
6
|
-
|
|
7
|
-
class << self
|
|
8
|
-
def email(html_body: "", header_url: "", footer_url: "", file_attachments: nil, to: "", from: nil, subject: "")
|
|
9
|
-
wording, images = DcidevMailer.format_image_from_html(html_body)
|
|
10
|
-
locals = {wording: wording, header: nil, footer: nil}
|
|
11
|
-
locals, images = DcidevMailer.format_header_footer(header_url: header_url, footer_url: footer_url, locals: locals, images: images) if header_url.present? && footer_url.present?
|
|
12
|
-
|
|
13
|
-
if file_attachments.present?
|
|
14
|
-
file_attachments.each do |a|
|
|
15
|
-
attachments[a[:name].to_s] = a[:content] unless a[:content].nil?
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
attachments.inline['header'] = File.read(Utility.download_to_file(header_url)) rescue nil if header_url.present?
|
|
20
|
-
attachments.inline['footer'] = File.read(Utility.download_to_file(footer_url)) rescue nil if footer_url.present?
|
|
21
|
-
|
|
22
|
-
mail(to: to, subject: subject, format: "text/html", from: from) do |format|
|
|
23
|
-
format.html {
|
|
24
|
-
render locals: locals
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|