mailgun_rails 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailgun/attachment.rb +16 -0
- data/lib/mailgun/deliverer.rb +22 -2
- data/lib/mailgun/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c56490bbbbccdbcc1af3de56f1975048a33a0ad
|
4
|
+
data.tar.gz: ce12417419f575f639c24166111cda0d00f94c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02eaffa49c0fc4f5b55a2d8f3308a936ca2f95204b59e3243eb728ea4cf426bf4e80894cc16a04df23901f80f1404c05d378aaae329131bbf80834ceac68b2f9
|
7
|
+
data.tar.gz: a9e10aa437d7ae83725694597962bbdfe573b00a4488f2bad922b26c3fdc24cb9d57bc2833ff6dae7081c96b38e79d53ed564696baeb4a8456b744a5223e6727
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mailgun
|
2
|
+
class Attachment < StringIO
|
3
|
+
attr_reader :original_filename, :content_type, :path
|
4
|
+
|
5
|
+
def initialize (attachment, *rest)
|
6
|
+
@path = ''
|
7
|
+
if rest.detect {|opt| opt[:inline] }
|
8
|
+
basename = @original_filename = attachment.cid
|
9
|
+
else
|
10
|
+
basename = @original_filename = attachment.filename
|
11
|
+
end
|
12
|
+
@content_type = attachment.content_type.split(';')[0]
|
13
|
+
super attachment.body.decoded
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/mailgun/deliverer.rb
CHANGED
@@ -38,8 +38,28 @@ module Mailgun
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def build_basic_mailgun_message_for(rails_message)
|
41
|
-
|
42
|
-
:
|
41
|
+
mailgun_message = {
|
42
|
+
from: rails_message[:from].formatted,
|
43
|
+
to: rails_message[:to].formatted,
|
44
|
+
subject: rails_message.subject,
|
45
|
+
html: extract_html(rails_message),
|
46
|
+
text: extract_text(rails_message)
|
47
|
+
}
|
48
|
+
return mailgun_message if rails_message.attachments.empty?
|
49
|
+
|
50
|
+
# RestClient requires attachments to be in file format, use a temp directory and the decoded attachment
|
51
|
+
mailgun_message[:attachment] = []
|
52
|
+
mailgun_message[:inline] = []
|
53
|
+
rails_message.attachments.each do |attachment|
|
54
|
+
# then add as a file object
|
55
|
+
if attachment.inline?
|
56
|
+
mailgun_message[:inline] << Mailgun::Attachment.new(attachment, encoding: 'ascii-8bit', inline: true)
|
57
|
+
else
|
58
|
+
mailgun_message[:attachment] << Mailgun::Attachment.new(attachment, encoding: 'ascii-8bit')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
return mailgun_message
|
43
63
|
end
|
44
64
|
|
45
65
|
def transform_reply_to(rails_message, mailgun_message)
|
data/lib/mailgun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailgun_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- MIT-LICENSE
|
77
77
|
- README.rdoc
|
78
78
|
- Rakefile
|
79
|
+
- lib/mailgun/attachment.rb
|
79
80
|
- lib/mailgun/client.rb
|
80
81
|
- lib/mailgun/deliverer.rb
|
81
82
|
- lib/mailgun/mail_ext.rb
|