remail-rails2 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ pkg
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Alexander MacCaw (info@eribium.org)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ Remail is RESTful email for Rails.
2
+
3
+ Forget configuring SMTP servers and queues, just use Remail.
4
+ Remail uses Google App Engine to send and receive emails RESTfully.
5
+
6
+ This gem (remail-rails2) only supports Rails 2.3
7
+
8
+ Google App Engine gives you a free quota of 2000 emails per day or, with the
9
+ paid version, 7,400,000 emails per day.
10
+
11
+ ## Features
12
+ * ActionMailer POSTs emails to your Remail App Engine in order to send them
13
+ * Remail POSTs received emails back to a configurable URL
14
+ * Remail will retry the callback if the endpoint is not available
15
+
16
+ ## Setup
17
+ * Configure and deploy the [Remail App Engine](http://github.com/maccman/remail-engine)
18
+ * Install the Remail gem (sudo gem install remail-rails2)
19
+
20
+ ## Sending email
21
+ Configure ActionMailer and Remail:
22
+
23
+ config.action_mailer.delivery_method = :remail
24
+ Remail.app_id = "remail-appname"
25
+ Remail.api_key = "changeme"
26
+
27
+ The sender address of a message must be the email address of an administrator for the Remail App Engine.
28
+ If you want to send email on behalf of the application but do not want to use a single administrator's personal Google Account as the sender, you can create a new Google Account for the application using any valid email address, then add the new account as an administrator for the application.
29
+
30
+ ## Misc
31
+
32
+ To ensure your email doesn't get caught in spam filters, you should follow the tips in this tutorial I [wrote](http://madebymany.co.uk/getting-email-around-spam-filters-00221) - the important points being setting SPF and MX records.
@@ -0,0 +1,13 @@
1
+ begin
2
+ require "jeweler"
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "remail-rails2"
5
+ gemspec.summary = "RESTful email"
6
+ gemspec.email = "martin+remail@schuerrer.org"
7
+ gemspec.homepage = "http://github.com/MSch/remail-rails2"
8
+ gemspec.authors = ["Alex MacCaw", "Martin Schuerrer"]
9
+ gemspec.add_dependency("activeresource")
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
13
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.7
@@ -0,0 +1,71 @@
1
+ require "active_resource"
2
+
3
+ module Remail
4
+ def site=(site)
5
+ Email.site = site
6
+ end
7
+ module_function :site=
8
+
9
+ def app_id=(name)
10
+ self.site = "http://#{name}.appspot.com"
11
+ end
12
+ module_function :app_id=
13
+
14
+ def api_key=(key)
15
+ Email.headers["Authorization"] = key
16
+ end
17
+ module_function :api_key=
18
+
19
+ class Email < ActiveResource::Base
20
+ self.timeout = 5
21
+ self.format = :json
22
+ self.element_name = "email"
23
+
24
+ cattr_accessor :headers
25
+ @@headers = {}
26
+
27
+ #schema do
28
+ # string :sender, :to, :cc, :bcc,
29
+ # :reply_to, :subject,
30
+ # :body, :html
31
+ #end
32
+
33
+ #validates_presence_of :sender, :to, :subject
34
+ #validates_presence_of :body, :unless => :html?
35
+
36
+ # The sender address must be the email address of a
37
+ # registered administrator for the application
38
+ def from=(address)
39
+ self.sender = address
40
+ end
41
+ end
42
+ end
43
+
44
+ begin
45
+ require "action_mailer"
46
+ module ActionMailer
47
+ class Base
48
+ def perform_delivery_remail(mail)
49
+ remail = Remail::Email.new
50
+
51
+ %w{to from cc bcc reply_to}.each {|attr|
52
+ value = mail.send(attr)
53
+ next unless value
54
+ remail.send("#{attr}=", value.join(", "))
55
+ }
56
+
57
+ remail.subject = mail.subject
58
+
59
+ text_body = select_mail_body(mail, 'text/plain')
60
+ html_body = select_mail_body(mail, 'text/html')
61
+ remail.body = text_body if text_body
62
+ remail.html = html_body if html_body
63
+ remail.save
64
+ end
65
+ def select_mail_body(mail, content_type)
66
+ mail.parts.select { |p| p.content_type == content_type }.try(:first).try(:body)
67
+ end
68
+ end
69
+ end
70
+ rescue LoadError
71
+ end
@@ -0,0 +1,45 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{remail-rails2}
8
+ s.version = "0.0.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alex MacCaw", "Martin Schuerrer"]
12
+ s.date = %q{2010-05-07}
13
+ s.email = %q{martin+remail@schuerrer.org}
14
+ s.extra_rdoc_files = [
15
+ "README.markdown"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "MIT-LICENSE",
20
+ "README.markdown",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/remail-rails2.rb",
24
+ "remail-rails2.gemspec"
25
+ ]
26
+ s.homepage = %q{http://github.com/MSch/remail-rails2}
27
+ s.rdoc_options = ["--charset=UTF-8"]
28
+ s.require_paths = ["lib"]
29
+ s.rubygems_version = %q{1.3.6}
30
+ s.summary = %q{RESTful email}
31
+
32
+ if s.respond_to? :specification_version then
33
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
37
+ s.add_runtime_dependency(%q<activeresource>, [">= 0"])
38
+ else
39
+ s.add_dependency(%q<activeresource>, [">= 0"])
40
+ end
41
+ else
42
+ s.add_dependency(%q<activeresource>, [">= 0"])
43
+ end
44
+ end
45
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remail-rails2
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 7
9
+ version: 0.0.7
10
+ platform: ruby
11
+ authors:
12
+ - Alex MacCaw
13
+ - Martin Schuerrer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-05-07 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activeresource
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description:
34
+ email: martin+remail@schuerrer.org
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README.markdown
41
+ files:
42
+ - .gitignore
43
+ - MIT-LICENSE
44
+ - README.markdown
45
+ - Rakefile
46
+ - VERSION
47
+ - lib/remail-rails2.rb
48
+ - remail-rails2.gemspec
49
+ has_rdoc: true
50
+ homepage: http://github.com/MSch/remail-rails2
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --charset=UTF-8
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.6
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: RESTful email
79
+ test_files: []
80
+