jwulff-actionmailer_multiple_smtp 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +44 -0
- data/Rakefile +74 -0
- data/lib/actionmailer_multiple_smtp.rb +29 -0
- data/spec/actionmailer_multiple_smtp_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +69 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 John Wulff
|
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,44 @@
|
|
1
|
+
= actionmailer_multiple_smtp
|
2
|
+
|
3
|
+
Gives ActionMailer ability to user different SMTP accounts based on a message's from address.
|
4
|
+
|
5
|
+
In your environments (config/environments/*.rb) add something like this to make mail from 'special_sender@domain.com' use the :username => 'special_sender' SMTP settings and all other mail use the :username => 'mailer' SMTP settings.
|
6
|
+
|
7
|
+
ActionMailer::Base.delivery_method = :smtp
|
8
|
+
ActionMailer::Base.smtp_settings = {
|
9
|
+
:address => 'smtp.domain.com',
|
10
|
+
:domain => 'domain.com',
|
11
|
+
:username => 'mailer',
|
12
|
+
:password => '******'
|
13
|
+
}
|
14
|
+
ActionMailer::Base.smtp_settings_by_from_address['special_sender@domain.com'] = {
|
15
|
+
:address => 'smtp.domain.com',
|
16
|
+
:domain => 'domain.com',
|
17
|
+
:username => 'special_sender',
|
18
|
+
:password => '******'
|
19
|
+
}
|
20
|
+
|
21
|
+
If you're using GMail for SMTP, install the tlsmail gem and add something like this to your environments:
|
22
|
+
|
23
|
+
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
|
24
|
+
ActionMailer::Base.delivery_method = :smtp
|
25
|
+
ActionMailer::Base.smtp_settings = {
|
26
|
+
:address => 'smtp.gmail.com',
|
27
|
+
:port => 587,
|
28
|
+
:domain => 'domain.com',
|
29
|
+
:user_name => 'user@domain.com',
|
30
|
+
:password => '******',
|
31
|
+
:authentication => :plain
|
32
|
+
}
|
33
|
+
ActionMailer::Base.smtp_settings_by_from_address['special_sender@domain.com'] = {
|
34
|
+
:address => 'smtp.gmail.com',
|
35
|
+
:port => 587,
|
36
|
+
:domain => 'domain.com',
|
37
|
+
:user_name => 'special_sender@domain.com',
|
38
|
+
:password => '******',
|
39
|
+
:authentication => :plain
|
40
|
+
}
|
41
|
+
|
42
|
+
== Copyright
|
43
|
+
|
44
|
+
Copyright (c) 2009 John Wulff. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "actionmailer_multiple_smtp"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "john@johnwulff.com"
|
10
|
+
gem.homepage = "http://github.com/jwulff/actionmailer_multiple_smtp"
|
11
|
+
gem.authors = ["John Wulff"]
|
12
|
+
gem.rubyforge_project = "actionmailer_multiple_smtp"
|
13
|
+
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
task :default => :spec
|
34
|
+
|
35
|
+
require 'rake/rdoctask'
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
if File.exist?('VERSION.yml')
|
38
|
+
config = YAML.load(File.read('VERSION.yml'))
|
39
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
40
|
+
else
|
41
|
+
version = ""
|
42
|
+
end
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "actionmailer_multiple_smtp #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'rake/contrib/sshpublisher'
|
52
|
+
namespace :rubyforge do
|
53
|
+
|
54
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
55
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
56
|
+
|
57
|
+
namespace :release do
|
58
|
+
desc "Publish RDoc to RubyForge."
|
59
|
+
task :docs => [:rdoc] do
|
60
|
+
config = YAML.load(
|
61
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
62
|
+
)
|
63
|
+
|
64
|
+
host = "#{config['username']}@rubyforge.org"
|
65
|
+
remote_dir = "/var/www/gforge-projects/actionmailer_multiple_smtp/"
|
66
|
+
local_dir = 'rdoc'
|
67
|
+
|
68
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
rescue LoadError
|
73
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
74
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'actionmailer'
|
2
|
+
|
3
|
+
class ActionMailer::Base
|
4
|
+
class << self
|
5
|
+
def smtp_settings_by_from_address
|
6
|
+
@smtp_settings_by_from_address ||= {}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def deliver_with_intelligent_smtp!(mail = @mail)
|
11
|
+
if ActionMailer::Base.smtp_settings_by_from_address[mail.from.first.downcase]
|
12
|
+
# Save the default email settings.
|
13
|
+
original_smtp_settings = self.class.smtp_settings
|
14
|
+
begin
|
15
|
+
# Apply the from address specific settings.
|
16
|
+
self.class.smtp_settings = ActionMailer::Base.smtp_settings_by_from_address[mail.from.first.downcase]
|
17
|
+
# Send the message.
|
18
|
+
deliver_without_intelligent_smtp! mail
|
19
|
+
ensure
|
20
|
+
# Return smtp_settings to original settings.
|
21
|
+
self.class.smtp_settings = original_smtp_settings
|
22
|
+
end
|
23
|
+
else
|
24
|
+
deliver_without_intelligent_smtp! mail
|
25
|
+
end
|
26
|
+
end
|
27
|
+
alias_method :deliver_without_intelligent_smtp!, :deliver!
|
28
|
+
alias_method :deliver!, :deliver_with_intelligent_smtp!
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jwulff-actionmailer_multiple_smtp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Wulff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: actionmailer
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: john@johnwulff.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- lib/actionmailer_multiple_smtp.rb
|
39
|
+
- spec/actionmailer_multiple_smtp_spec.rb
|
40
|
+
- spec/spec_helper.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/jwulff/actionmailer_multiple_smtp
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project: actionmailer_multiple_smtp
|
63
|
+
rubygems_version: 1.2.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 2
|
66
|
+
summary: TODO
|
67
|
+
test_files:
|
68
|
+
- spec/actionmailer_multiple_smtp_spec.rb
|
69
|
+
- spec/spec_helper.rb
|