appmail 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf42054c6e347a5c7cad150857aa334eab7e5ea6
4
- data.tar.gz: 6a1e0e40ed2c04a67232875132d9d2dddb4ad7ee
3
+ metadata.gz: 0ee3732c7781832a279ec3de521f3ee47a955644
4
+ data.tar.gz: 53ce38e91861e7756c2aa023700b39511266ff60
5
5
  SHA512:
6
- metadata.gz: b7e91f5b55dff971e14a56a146684d23666737209459d40c01da057f985e2b1bc5903667357ae4eaea8b8cd489ebe8d87ff526f745748c673af9492f8ba40386
7
- data.tar.gz: 9d90c3d37b84bfe5e8585d9a72607ab214b137765d2afb952d16dc144102d1562f5b9da7e2cd18fcacc171aaccd476d1162a2d84e99ead6e27c5afb8dad37970
6
+ metadata.gz: 48b81964751d37f35f5195ab31df8080554e73c5256aad0a585a3efbaa1998f7639b4749879cd147ae1f7cd217c48e5b1ab8a5c1bbb3be3be7075445f6d1261f
7
+ data.tar.gz: 74319ac1e5a905c2c782eb85963b018d5832d39e5d245336bafebb00aada90bc79bfbd86505a726100e71203ee20bd839264298a078fd1656607a70367691281
@@ -15,4 +15,8 @@ module AppMail
15
15
  AppMail::Client.instance.send_message(&block)
16
16
  end
17
17
 
18
+ def self.send_raw_message(&block)
19
+ AppMail::Client.instance.send_raw_message(&block)
20
+ end
21
+
18
22
  end
@@ -1,6 +1,7 @@
1
1
  require 'moonrope_client'
2
2
  require 'app_mail/message_scope'
3
3
  require 'app_mail/send_message'
4
+ require 'app_mail/send_raw_message'
4
5
 
5
6
  module AppMail
6
7
  class Client
@@ -37,6 +38,15 @@ module AppMail
37
38
  message.send!
38
39
  end
39
40
 
41
+ #
42
+ # Send a raw message
43
+ #
44
+ def send_raw_message(&block)
45
+ message = SendRawMessage.new(self)
46
+ block.call(message)
47
+ message.send!
48
+ end
49
+
40
50
  #
41
51
  # Return the backend moonrope instance for this client
42
52
  #
@@ -24,6 +24,10 @@ module AppMail
24
24
  @attributes[:from] = address
25
25
  end
26
26
 
27
+ def sender(address)
28
+ @attributes[:sender] = address
29
+ end
30
+
27
31
  def to(*addresses)
28
32
  @attributes[:to] ||= []
29
33
  @attributes[:to] += addresses
@@ -0,0 +1,37 @@
1
+ require 'base64'
2
+ require 'app_mail/send_result'
3
+
4
+ module AppMail
5
+ class SendRawMessage
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ @attributes = {}
10
+ end
11
+
12
+ def send!
13
+ api = @client.moonrope.request(:send, :raw, @attributes)
14
+ if api.success?
15
+ SendResult.new(@client, api.data)
16
+ elsif api.status == 'error'
17
+ raise SendError.new(api.data['code'], api.data['message'])
18
+ else
19
+ raise Error, "Couldn't send message"
20
+ end
21
+ end
22
+
23
+ def mail_from(address)
24
+ @attributes[:mail_from] = address
25
+ end
26
+
27
+ def rcpt_to(*addresses)
28
+ @attributes[:rcpt_to] ||= []
29
+ @attributes[:rcpt_to] += addresses
30
+ end
31
+
32
+ def data(data)
33
+ @attributes[:data] = Base64.encode64(data)
34
+ end
35
+
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module AppMail
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-29 00:00:00.000000000 Z
11
+ date: 2016-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: moonrope-client
@@ -46,6 +46,7 @@ files:
46
46
  - lib/app_mail/message.rb
47
47
  - lib/app_mail/message_scope.rb
48
48
  - lib/app_mail/send_message.rb
49
+ - lib/app_mail/send_raw_message.rb
49
50
  - lib/app_mail/send_result.rb
50
51
  - lib/app_mail/version.rb
51
52
  - lib/appmail.rb