sendgmail 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "tmail", ">= 1.2.7.1"
7
+ gem "tlsmail", ">= 0.0.1"
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "rspec", "~> 2.3.0"
13
+ gem "bundler", "~> 1.0.0"
14
+ gem "jeweler", "~> 1.5.2"
15
+ gem "rcov", ">= 0"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ rcov (0.9.9)
12
+ rspec (2.3.0)
13
+ rspec-core (~> 2.3.0)
14
+ rspec-expectations (~> 2.3.0)
15
+ rspec-mocks (~> 2.3.0)
16
+ rspec-core (2.3.1)
17
+ rspec-expectations (2.3.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.3.0)
20
+ tlsmail (0.0.1)
21
+ tmail (1.2.7.1)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ bundler (~> 1.0.0)
28
+ jeweler (~> 1.5.2)
29
+ rcov
30
+ rspec (~> 2.3.0)
31
+ tlsmail (>= 0.0.1)
32
+ tmail (>= 1.2.7.1)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 HAMANAKA, Kei
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.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = sendgmail
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to sendgmail
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 HAMANAKA, Kei. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "sendgmail"
16
+ gem.homepage = "http://github.com/hamanaka/sendgmail"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{A library for sending a mail from Gmail.}
19
+ gem.description = %Q{A library for sending a mail from Gmail.}
20
+ gem.email = "kei.hamanaka@gmail.com"
21
+ gem.authors = ["HAMANAKA, Kei"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "sendgmail #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.0
data/lib/sendgmail.rb ADDED
@@ -0,0 +1,82 @@
1
+ require 'tmail'
2
+ require 'tlsmail'
3
+
4
+ module SendGmail #:nodoc:
5
+ class Config
6
+ # Gmail account
7
+ attr_accessor :account
8
+ # Gmail password
9
+ attr_accessor :password
10
+ # Gmail smtp_domain
11
+ attr_accessor :smtp_domain
12
+ # Gmail smtp_port
13
+ attr_accessor :smtp_port
14
+
15
+ def initialize(&block)
16
+ block.call(self)
17
+ end
18
+ end
19
+
20
+ class Client
21
+ SMTP_DOMAIN = "smtp.gmail.com"
22
+ SMTP_PORT = 587
23
+ DEFAULT_DATE = Time.now
24
+ DEFAULT_MIME_VESION = "1.0"
25
+
26
+ # creates a new Gmail client instance.
27
+ #
28
+ # SendGmail::Client.new do |c|
29
+ # c.account = "your.address@gmail.com"
30
+ # c.password = "yourpassword"
31
+ # end
32
+ #
33
+ def initialize(args = {}, &block)
34
+ @config = Config.new do |c|
35
+ c.account = args[:account]
36
+ c.password = args[:password]
37
+ c.smtp_domain = args[:smtp_domain] ||= SMTP_DOMAIN
38
+ c.smtp_port = args[:smtp_port] ||= SMTP_PORT
39
+ end
40
+ if block_given?
41
+ block.call @config
42
+ end
43
+ end
44
+
45
+ # send your mail from Gmail.
46
+ #
47
+ # client.send(
48
+ # :to => 'foo.bar@gmail.com',
49
+ # :from => 'your.address@gmail.com',
50
+ # :subject => 'hello',
51
+ # :body => 'world'
52
+ # end
53
+ #
54
+ def send(params = {})
55
+ mail = create_mail(params)
56
+
57
+ ::Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
58
+ ::Net::SMTP.start(
59
+ @config.smtp_domain,
60
+ @config.smtp_port,
61
+ "localhost.localdomain",
62
+ @config.account,
63
+ @config.password,
64
+ "plain"){ |smtp|
65
+ smtp.sendmail(mail.encoded, mail.from, mail.to)
66
+ }
67
+ end
68
+
69
+ def create_mail(params ={})
70
+ mail = ::TMail::Mail.new
71
+ mail.to = params[:to]
72
+ mail.from = params[:from]
73
+ mail.subject = params[:subject]
74
+ mail.date = params[:date] ||= DEFAULT_DATE
75
+ mail.mime_version = params[:mime_version] ||= DEFAULT_MIME_VESION
76
+ mail.set_content_type 'text', 'plain', {'charset'=>'iso-2022-jp'}
77
+ mail.body = params[:body]
78
+ return mail
79
+ end
80
+
81
+ end
82
+ end
data/sendgmail.gemspec ADDED
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sendgmail}
8
+ s.version = "0.5.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["HAMANAKA, Kei"]
12
+ s.date = %q{2010-12-23}
13
+ s.description = %q{A library for sending a mail from Gmail.}
14
+ s.email = %q{kei.hamanaka@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/sendgmail.rb",
29
+ "sendgmail.gemspec",
30
+ "spec/sendgmail_spec.rb",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/hamanaka/sendgmail}
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.7}
37
+ s.summary = %q{A library for sending a mail from Gmail.}
38
+ s.test_files = [
39
+ "spec/sendgmail_spec.rb",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<tmail>, [">= 1.2.7.1"])
49
+ s.add_runtime_dependency(%q<tlsmail>, [">= 0.0.1"])
50
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
+ s.add_development_dependency(%q<rcov>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<tmail>, [">= 1.2.7.1"])
56
+ s.add_dependency(%q<tlsmail>, [">= 0.0.1"])
57
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
60
+ s.add_dependency(%q<rcov>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<tmail>, [">= 1.2.7.1"])
64
+ s.add_dependency(%q<tlsmail>, [">= 0.0.1"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ end
70
+ end
71
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Sendgmail" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'sendgmail'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sendgmail
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
+ platform: ruby
12
+ authors:
13
+ - HAMANAKA, Kei
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-23 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ prerelease: false
24
+ name: tmail
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 81
31
+ segments:
32
+ - 1
33
+ - 2
34
+ - 7
35
+ - 1
36
+ version: 1.2.7.1
37
+ requirement: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ type: :runtime
40
+ prerelease: false
41
+ name: tlsmail
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 29
48
+ segments:
49
+ - 0
50
+ - 0
51
+ - 1
52
+ version: 0.0.1
53
+ requirement: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ type: :development
56
+ prerelease: false
57
+ name: rspec
58
+ version_requirements: &id003 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 2
66
+ - 3
67
+ - 0
68
+ version: 2.3.0
69
+ requirement: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ type: :development
72
+ prerelease: false
73
+ name: bundler
74
+ version_requirements: &id004 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ hash: 23
80
+ segments:
81
+ - 1
82
+ - 0
83
+ - 0
84
+ version: 1.0.0
85
+ requirement: *id004
86
+ - !ruby/object:Gem::Dependency
87
+ type: :development
88
+ prerelease: false
89
+ name: jeweler
90
+ version_requirements: &id005 !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ hash: 7
96
+ segments:
97
+ - 1
98
+ - 5
99
+ - 2
100
+ version: 1.5.2
101
+ requirement: *id005
102
+ - !ruby/object:Gem::Dependency
103
+ type: :development
104
+ prerelease: false
105
+ name: rcov
106
+ version_requirements: &id006 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ requirement: *id006
116
+ description: A library for sending a mail from Gmail.
117
+ email: kei.hamanaka@gmail.com
118
+ executables: []
119
+
120
+ extensions: []
121
+
122
+ extra_rdoc_files:
123
+ - LICENSE.txt
124
+ - README.rdoc
125
+ files:
126
+ - .document
127
+ - .rspec
128
+ - Gemfile
129
+ - Gemfile.lock
130
+ - LICENSE.txt
131
+ - README.rdoc
132
+ - Rakefile
133
+ - VERSION
134
+ - lib/sendgmail.rb
135
+ - sendgmail.gemspec
136
+ - spec/sendgmail_spec.rb
137
+ - spec/spec_helper.rb
138
+ has_rdoc: true
139
+ homepage: http://github.com/hamanaka/sendgmail
140
+ licenses:
141
+ - MIT
142
+ post_install_message:
143
+ rdoc_options: []
144
+
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ hash: 3
153
+ segments:
154
+ - 0
155
+ version: "0"
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
165
+ requirements: []
166
+
167
+ rubyforge_project:
168
+ rubygems_version: 1.3.7
169
+ signing_key:
170
+ specification_version: 3
171
+ summary: A library for sending a mail from Gmail.
172
+ test_files:
173
+ - spec/sendgmail_spec.rb
174
+ - spec/spec_helper.rb