actionmailer-ironruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +11 -0
- data/init.rb +1 -0
- data/lib/actionmailer-ironruby.rb +79 -0
- metadata +57 -0
data/README
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
= actionmailer-ironruby
|
2
|
+
|
3
|
+
== DESCRIPTION
|
4
|
+
|
5
|
+
ActionMailer-IronRuby makes it possible for users of the IronRuby runtime to use
|
6
|
+
the .NET framework's built-in email handling capabilities for sending emails
|
7
|
+
with ActionMailer.
|
8
|
+
|
9
|
+
== TODO
|
10
|
+
|
11
|
+
* Add ability to handle receiving emails as well
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'actionmailer-ironruby' if (defined? RUBY_ENGINE && RUBY_ENGINE == "ironruby")
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) 2009 James Thompson <james@plainprograms.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
load_assembly 'System.Net'
|
22
|
+
|
23
|
+
class ActionMailer
|
24
|
+
module DeliveryMethod
|
25
|
+
class Ironruby < Method
|
26
|
+
include System::Net
|
27
|
+
include System::Net::Mail
|
28
|
+
|
29
|
+
self.settings = {
|
30
|
+
:address => "localhost",
|
31
|
+
:port => 25,
|
32
|
+
:user_name => nil,
|
33
|
+
:password => nil,
|
34
|
+
:delivery_method => :network,
|
35
|
+
:delivery_folder => nil
|
36
|
+
}
|
37
|
+
|
38
|
+
def perform_delivery(mail)
|
39
|
+
message = MailMessage.new
|
40
|
+
|
41
|
+
message.From = MailAddress.new(mail.sender_addr.spec, mail.sender_addr.name)
|
42
|
+
message.ReplyTo = MailAddress.new(mail.reply_to_addrs.spec, mail.reply_to_addrs.name)
|
43
|
+
|
44
|
+
mail.to_addrs.each do |address|
|
45
|
+
recipient = MailAddress.new(address.spec, address.name)
|
46
|
+
message.To.Add(recipient)
|
47
|
+
end
|
48
|
+
|
49
|
+
mail.cc_addrs.each do |address|
|
50
|
+
recipient = MailAddress.new(address.spec, address.name)
|
51
|
+
message.CC.Add(recipient)
|
52
|
+
end
|
53
|
+
|
54
|
+
mail.bcc_addrs.each do |address|
|
55
|
+
recipient = MailAddress.new(address.spec, address.name)
|
56
|
+
message.Bcc.Add(recipient)
|
57
|
+
end
|
58
|
+
|
59
|
+
message.subject = mail.subject
|
60
|
+
|
61
|
+
unless mail.multipart?
|
62
|
+
message.Body = mail.body
|
63
|
+
else
|
64
|
+
message.parts.each do |part|
|
65
|
+
content_type = part.content_type
|
66
|
+
content = part.body
|
67
|
+
|
68
|
+
view = AlternateView.CreateAlternateViewFromString(content, content_type)
|
69
|
+
message.AlternateViews.Add(view)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
smtp = SmtpClient.new(settings[:address], settings[:port])
|
74
|
+
smtp.Credentials = NetworkCredential.new(settings[:user_name], settings[:password]) if settings[:user_name] && settings[:password]
|
75
|
+
smtp.Send(message)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actionmailer-ironruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Thompson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-05 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A plugin for Rails to integrate ActionMailer with the System.Net.Mail assembly when deploying with IronRuby.
|
17
|
+
email: james@plainprograms.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- lib/actionmailer-ironruby.rb
|
27
|
+
- init.rb
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://github.com/jwthompson2/actionmailer-ironruby
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.3.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Integrate ActionMailer with .NET for IronRuby
|
56
|
+
test_files: []
|
57
|
+
|