dcidev_mailer 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bce233b1357d66de38ad38b886e287bf67ffdaa4aea36a926baba5787d0edaa
4
- data.tar.gz: f4145c04c507c7dec980607cc92d56d8031d98c8745209a3a562b3d4816a1f14
3
+ metadata.gz: cd7fa21ca61b2ed6a524f4c82023b37d51ca3282bd8a25995031d69000b4135a
4
+ data.tar.gz: 3609eec64b5a8dbe5f54b688127e87b6f1262c7f2a33d8f9a488d8f696af226b
5
5
  SHA512:
6
- metadata.gz: 411ffdeabdab7482555150e620c13b9a05b938017c3e771149d061830ee9e8c2759bffa83efcc46a555d0de57dfec24757d3869ebe8b63c1c4720d5e85742568
7
- data.tar.gz: 85f8987917de61a5231f345a016309003749e3e41655332662d6e17650e334e77479bdaf1492700d7bcc41fcfb7f1b42b87d75101a8483f534e4058c748f514e
6
+ metadata.gz: f13f0791eed210a1c308e507ccc7f399b8d7d91238e96f93f760a455e4f212a69009f79cf4512fe9d936ecfe3d96390115e1f187f37362028dc553cae231dd99
7
+ data.tar.gz: 543a1243fdd008d1624b97b8ad515fefe636dc1e4639044534a7fccc10f1dc4e7b34d56b5148aba0c210fd2c700b79ee3db676f2815239bbe291547a09d77fcb
@@ -0,0 +1,44 @@
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
+ if file_attachments.present?
20
+ file_attachments.each do |a|
21
+ ActionMailer::Base.attachments[a[:name].to_s] = a[:content] unless a[:content].nil?
22
+ end
23
+ end
24
+ # ActionMailer::Base.new.attachments.inline
25
+ att.attachments.inline['header'] = File.read(Utility.download_to_file(header_url)) rescue nil if header_url.present?
26
+ att.attachments.inline['footer'] = File.read(Utility.download_to_file(footer_url)) rescue nil if footer_url.present?
27
+
28
+ ActionMailer::Base.mail(
29
+ to: to,
30
+ subject: subject,
31
+ format: "text/html",
32
+ from: from,
33
+ template_path: template_path,
34
+ template_name: template_name
35
+ ) do |format|
36
+ format.html {
37
+ ActionView::Base.new.render locals: locals
38
+ }
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dcidev_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Punto Damar P
@@ -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: {}
@@ -1,30 +0,0 @@
1
- require 'mail'
2
-
3
- module DcidevMailer
4
- class Rails < ActionMailer::Base
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
30
- end