emaily 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +0 -0
- data/bin/emaily +243 -0
- data/bin/emaily_genlist +9 -0
- data/bin/qp_decoder +67 -0
- data/lib/emaily.rb +14 -0
- data/lib/emaily/csv.rb +19 -0
- data/lib/emaily/emaily.rb +117 -0
- data/lib/emaily/servers.rb +43 -0
- data/lib/emaily/skydrive.rb +20 -0
- data/lib/emaily/templates.rb +38 -0
- data/lib/emaily/webserver.rb +0 -0
- data/templates/test_template.html +12 -0
- metadata +74 -0
data/README
ADDED
File without changes
|
data/bin/emaily
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -wKU
|
3
|
+
# emaily
|
4
|
+
#
|
5
|
+
# Created by FreedomCoder on 2010-1-26.
|
6
|
+
# Copyright 2010 FreedomCoder's Labs. All rights reserved.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'getoptlong'
|
11
|
+
require 'emaily'
|
12
|
+
|
13
|
+
EMaily::log = true
|
14
|
+
@data = {}
|
15
|
+
@server = {}
|
16
|
+
|
17
|
+
opts = GetoptLong.new(
|
18
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
19
|
+
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
20
|
+
[ '--nolog', GetoptLong::NO_ARGUMENT ],
|
21
|
+
[ '--show-templates', GetoptLong::NO_ARGUMENT ],
|
22
|
+
[ '--webserver', GetoptLong::NO_ARGUMENT ],
|
23
|
+
[ '--random', GetoptLong::NO_ARGUMENT ],
|
24
|
+
[ '--skydrive', GetoptLong::NO_ARGUMENT ],
|
25
|
+
[ '--remove-server', GetoptLong::NO_ARGUMENT ],
|
26
|
+
[ '--add-server', GetoptLong::NO_ARGUMENT ],
|
27
|
+
[ '--name','-n', GetoptLong::REQUIRED_ARGUMENT ],
|
28
|
+
[ '--uri','-w', GetoptLong::REQUIRED_ARGUMENT ],
|
29
|
+
[ '--port','-p', GetoptLong::REQUIRED_ARGUMENT ],
|
30
|
+
[ '--domain','-d', GetoptLong::REQUIRED_ARGUMENT ],
|
31
|
+
[ '--authentication', GetoptLong::REQUIRED_ARGUMENT ],
|
32
|
+
[ '--ssl', GetoptLong::NO_ARGUMENT],
|
33
|
+
[ '--user','-U', GetoptLong::REQUIRED_ARGUMENT ],
|
34
|
+
[ '--pass','-P', GetoptLong::REQUIRED_ARGUMENT ],
|
35
|
+
[ '--template','-t', GetoptLong::REQUIRED_ARGUMENT ],
|
36
|
+
[ '--list','-l', GetoptLong::REQUIRED_ARGUMENT ],
|
37
|
+
[ '--from','-f', GetoptLong::REQUIRED_ARGUMENT ],
|
38
|
+
[ '--block','-b', GetoptLong::REQUIRED_ARGUMENT ],
|
39
|
+
[ '--sleep','-z', GetoptLong::REQUIRED_ARGUMENT ],
|
40
|
+
[ '--subject','-s', GetoptLong::REQUIRED_ARGUMENT ],
|
41
|
+
[ '--attachment','-a', GetoptLong::REQUIRED_ARGUMENT ],
|
42
|
+
[ '--content-type','-c', GetoptLong::REQUIRED_ARGUMENT ],
|
43
|
+
[ '--output','-o', GetoptLong::REQUIRED_ARGUMENT ],
|
44
|
+
[ '--server','-S', GetoptLong::REQUIRED_ARGUMENT ]
|
45
|
+
)
|
46
|
+
|
47
|
+
def logo()
|
48
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
49
|
+
puts "___________ .__.__ "
|
50
|
+
puts "\\_ _____/ _____ _____ |__| | ___.__."
|
51
|
+
puts "| __)_ / \\__ \\ | | |< | |"
|
52
|
+
puts "| \\ Y Y \\/ __ \\| | |_\\___ |"
|
53
|
+
puts "/_______ /__|_| (____ /__|____/ ____|"
|
54
|
+
puts " \\/ \\/ \\/ \\/"
|
55
|
+
else
|
56
|
+
puts "\033[31m___________\033\[0m .__.__ "
|
57
|
+
puts "\033[31m\\_ _____/\033\[0m_____ _____ |__| | ___.__."
|
58
|
+
puts "\033[31m| __)\033\[0m _/ \\__ \\ | | |< | |"
|
59
|
+
puts "\033[31m| \\\033\[0m Y Y \\/ __ \\| | |_\\___ |"
|
60
|
+
puts "\033[31m/_______ /\033\[0m__|_| (____ /__|____/ ____| "
|
61
|
+
puts "\033[31m \\/\033\[0m \\/ \\/ \\/ "
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.each do |opt, arg|
|
66
|
+
case opt
|
67
|
+
when '--help' then
|
68
|
+
# BEGIN OF HELP
|
69
|
+
logo()
|
70
|
+
puts "\n\nHELP for EMaily\n---------------------\n"
|
71
|
+
puts "--help, -h"
|
72
|
+
puts "\tWell I guess you know what this is for (To obtain this Help).\n"
|
73
|
+
puts "--nolog"
|
74
|
+
puts "\tTells EMaily not to output to STDOUT.\n"
|
75
|
+
puts "ADD SERVER:"
|
76
|
+
puts "--add-server "
|
77
|
+
puts "\t --name, -n [name]\n"
|
78
|
+
puts "\t\t The name we will use to refer it.\n"
|
79
|
+
puts "\t --uri, -w [smtp.server.com]"
|
80
|
+
puts "\t\t The smtp server's uri.\n"
|
81
|
+
puts "\t--port, -p [number]"
|
82
|
+
puts "\t\t The server's port.\n"
|
83
|
+
puts "\t--domain, -d [domain]"
|
84
|
+
puts "\t\t The user's domain.\n"
|
85
|
+
puts "\t--authentication [type]"
|
86
|
+
puts "\t\t The server's authentication type.\n"
|
87
|
+
puts "\t--ssl"
|
88
|
+
puts "\t\t The server's security\n"
|
89
|
+
puts "--user, -U [username]"
|
90
|
+
puts "\t The server's username .\n"
|
91
|
+
puts "--pass, -P [password]"
|
92
|
+
puts "\t The server's password .\n\n"
|
93
|
+
puts "INPUT VARIABLES"
|
94
|
+
puts "--show-templates\n"
|
95
|
+
puts "\t Shows a list of available templates and needed fields"
|
96
|
+
puts "--template, -t [name/path]\n"
|
97
|
+
puts "\t The template path or name"
|
98
|
+
puts "--from, -f [email address] "
|
99
|
+
puts "\tEmail address of who is sending the emails.\n"
|
100
|
+
puts "--subject, -s [subject]"
|
101
|
+
puts "\t The email subject. If using Templates this is not necesary\n"
|
102
|
+
puts "--list, -l"
|
103
|
+
puts "\tThe CSV file that will populate the templates.\n"
|
104
|
+
puts "--attachment, -a [file1,file2,file3]\n"
|
105
|
+
puts "\t The attachment file/s \n"
|
106
|
+
puts "--content-type, -c [text/html; charset=UTF-8]"
|
107
|
+
puts "\t The content type used on the email. Default: text/html; charset=UTF-8\n"
|
108
|
+
puts "--server, -S [server1,server2,server3]\n"
|
109
|
+
puts "\t The server/s to send emails\n"
|
110
|
+
puts "Copyright 2010 - FreedomCoder\n"
|
111
|
+
#END OF HELP
|
112
|
+
exit(0)
|
113
|
+
when '--version' then
|
114
|
+
logo()
|
115
|
+
puts "EMaily version #{EMaily::VERSION}"
|
116
|
+
exit(0)
|
117
|
+
when '--nolog' then
|
118
|
+
EMaily::log = false
|
119
|
+
# ADD / REMOVE SERVER
|
120
|
+
when '--add-server' then
|
121
|
+
@add_server = true
|
122
|
+
when '--remove-server' then
|
123
|
+
@remove_server = true
|
124
|
+
when '--name' then
|
125
|
+
@server_name = arg
|
126
|
+
when '--uri' then
|
127
|
+
@server[:address] = arg
|
128
|
+
when '--port' then
|
129
|
+
@server[:port] = arg.to_i
|
130
|
+
when '--domain' then
|
131
|
+
@server[:domain] = arg
|
132
|
+
when '--user' then
|
133
|
+
@server[:user_name] = arg
|
134
|
+
when '--authentication' then
|
135
|
+
@server[:authentication] = arg
|
136
|
+
when '--pass' then
|
137
|
+
@server[:password] = arg
|
138
|
+
when '--ssl' then
|
139
|
+
@server[:enable_starttls_auto] = true
|
140
|
+
# END ADD / REMOVE SERVER
|
141
|
+
when '--block' then
|
142
|
+
@block = arg.to_i
|
143
|
+
when '--sleep' then
|
144
|
+
@sleep = arg.to_i
|
145
|
+
when '--random' then
|
146
|
+
@random = true
|
147
|
+
when '--template' then
|
148
|
+
if File.exist?(arg)
|
149
|
+
@data[:template] = arg
|
150
|
+
else
|
151
|
+
puts "The template path/file does not exists"
|
152
|
+
exit(0)
|
153
|
+
end
|
154
|
+
when '--from' then
|
155
|
+
@data[:from] = arg
|
156
|
+
when '--subject' then
|
157
|
+
@data[:subject] = arg
|
158
|
+
when '--list' then
|
159
|
+
@data[:list] = arg
|
160
|
+
when '--show-templates' then
|
161
|
+
logo
|
162
|
+
show_templates
|
163
|
+
exit(0)
|
164
|
+
when '--attachment' then
|
165
|
+
@data[:attachment] = arg.chomp.split(",")
|
166
|
+
when '--content-type' then
|
167
|
+
@data[:content_type] = arg
|
168
|
+
when '--server' then
|
169
|
+
@data[:servers] = arg.chomp.split(",")
|
170
|
+
else
|
171
|
+
puts "Unknown command. Please try again"
|
172
|
+
exit(0)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def add_server
|
177
|
+
servers = EMaily::Servers.load
|
178
|
+
servers.create(@server_name, @server)
|
179
|
+
servers.flush
|
180
|
+
end
|
181
|
+
|
182
|
+
def remove_server
|
183
|
+
servers = EMaily::Servers.load
|
184
|
+
servers.delete(@server_name)
|
185
|
+
server.flush
|
186
|
+
end
|
187
|
+
|
188
|
+
def check_template(name)
|
189
|
+
Gem.path.each do |path|
|
190
|
+
if File.exist?(path + "/emaily-#{EMaily::VERSION}/templates/#{name}.html")
|
191
|
+
return path + "/emaily-#{EMaily::VERSION}/templates/#{name}.html"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
return false
|
195
|
+
end
|
196
|
+
|
197
|
+
def show_templates
|
198
|
+
puts "Templates:"
|
199
|
+
Gem.path.each do |path|
|
200
|
+
Dir[path + "/emaily-#{EMaily::VERSION}/templates/**/*.*"].each_with_index do |t,idx|
|
201
|
+
puts "\t" + idx + ") " + t
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def execute
|
207
|
+
session = EMaily::Email.new(@data)
|
208
|
+
if session.serv.size < 2
|
209
|
+
@block != nil ? session.send_block(@block, @sleep) : session.send
|
210
|
+
elsif @random
|
211
|
+
session.send_to_random_servers(@block, @sleep)
|
212
|
+
else
|
213
|
+
session.send_to_servers(@block, @sleep)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
logo()
|
218
|
+
puts "\n"
|
219
|
+
puts "DISCLOSURE: This code is not bug free. If you find one do not hesitate to report it."
|
220
|
+
puts "All bugs are greatly appreciate it."
|
221
|
+
puts "------------------------------------------------------------------------"
|
222
|
+
|
223
|
+
if @add_server
|
224
|
+
add_server
|
225
|
+
D "Server #{@name} created."
|
226
|
+
exit(1)
|
227
|
+
elsif @remove_server
|
228
|
+
remove_server
|
229
|
+
D "Server #{@name} deleted."
|
230
|
+
exit(1)
|
231
|
+
end
|
232
|
+
|
233
|
+
if @data[:servers] == nil
|
234
|
+
D "You need to add at least 1 server."
|
235
|
+
exit(0)
|
236
|
+
end
|
237
|
+
|
238
|
+
unless @data.empty?
|
239
|
+
execute
|
240
|
+
end
|
241
|
+
|
242
|
+
puts "\n------------------------"
|
243
|
+
puts "Happy Hacking :)\nGood Bye.\n"
|
data/bin/emaily_genlist
ADDED
data/bin/qp_decoder
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'getoptlong'
|
3
|
+
|
4
|
+
opts = GetoptLong.new(
|
5
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
6
|
+
[ '--input','-i', GetoptLong::REQUIRED_ARGUMENT ],
|
7
|
+
[ '--output','-o', GetoptLong::REQUIRED_ARGUMENT ]
|
8
|
+
)
|
9
|
+
|
10
|
+
opts.each do |opt, arg|
|
11
|
+
case opt
|
12
|
+
when '--help' then
|
13
|
+
# BEGIN OF HELP
|
14
|
+
puts "nHELP for qp_decoder\n---------------------\n"
|
15
|
+
puts "--help, -h"
|
16
|
+
puts "\tWell I guess you know what this is for (To obtain this Help).\n"
|
17
|
+
puts "--input, -i"
|
18
|
+
puts "\tFile to convert.\n"
|
19
|
+
puts "--output, -o"
|
20
|
+
puts "\tFile to save. (Otherwise, it will overwrite input)\n"
|
21
|
+
puts "Copyright 2010 - FreedomCoder\n"
|
22
|
+
#END OF HELP
|
23
|
+
exit(0)
|
24
|
+
when '--input' then
|
25
|
+
@in = arg
|
26
|
+
when '--output' then
|
27
|
+
@out = arg
|
28
|
+
else
|
29
|
+
puts "option not recognized.\n"
|
30
|
+
exit(1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class QuotedPrintable
|
35
|
+
def initialize(input,output)
|
36
|
+
@text = ""
|
37
|
+
@data = File.readlines(input)
|
38
|
+
@input = input
|
39
|
+
@output = output
|
40
|
+
end
|
41
|
+
|
42
|
+
def decode
|
43
|
+
@data.each do |line|
|
44
|
+
@text << from_qp(line.chomp + "\r\n") + "\r\n"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def save
|
49
|
+
File.open((@output || @input), "w") {|x| x << @text }
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def from_qp(line)
|
54
|
+
result = line.gsub(/=\r\n/, "")
|
55
|
+
result.gsub!(/\r\n/m, $/)
|
56
|
+
result.gsub!(/=([\dA-F]{2})/) { $1.hex.chr }
|
57
|
+
result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
x = QuotedPrintable.new(@in, @out || nil)
|
62
|
+
x.decode
|
63
|
+
x.save
|
64
|
+
|
65
|
+
puts "\n------------------------"
|
66
|
+
puts "Happy Hacking :)\nGood Bye.\n"
|
67
|
+
|
data/lib/emaily.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mail'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
require 'emaily/csv'
|
6
|
+
require 'emaily/servers'
|
7
|
+
require 'emaily/webserver'
|
8
|
+
require 'emaily/templates'
|
9
|
+
require 'emaily/emaily'
|
10
|
+
|
11
|
+
|
12
|
+
### USE CASES
|
13
|
+
|
14
|
+
# > emaily -email templates/facebook.html -subject "Facebook Invitation" -list emails.csv
|
data/lib/emaily/csv.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module EMaily
|
2
|
+
class CSV
|
3
|
+
def self.parse(file)
|
4
|
+
list = []
|
5
|
+
f = File.open(file, "r")
|
6
|
+
lines = f.readlines
|
7
|
+
fields = lines[0].downcase.strip.split(",")
|
8
|
+
lines.delete(lines[0])
|
9
|
+
lines.each_with_index do |line, i|
|
10
|
+
list[i] = {}
|
11
|
+
line.chop.split(",").each_with_index do |val, idx|
|
12
|
+
list[i][fields[idx].strip.to_sym] = val.strip
|
13
|
+
end
|
14
|
+
end
|
15
|
+
list
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
def D m
|
2
|
+
puts m if EMaily::log
|
3
|
+
end
|
4
|
+
|
5
|
+
module EMaily
|
6
|
+
@@log = false
|
7
|
+
VERSION = 0.1
|
8
|
+
|
9
|
+
def self.log
|
10
|
+
@@log
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.log=(v)
|
14
|
+
@@log=v
|
15
|
+
end
|
16
|
+
|
17
|
+
class Email
|
18
|
+
def initialize(args)
|
19
|
+
#setup
|
20
|
+
EMaily.log = args[:log] if args[:log]
|
21
|
+
@servers = Servers.load
|
22
|
+
#variables
|
23
|
+
@list = CSV.parse(args[:list])
|
24
|
+
@attach = args[:attachment] || []
|
25
|
+
@from = args[:from]
|
26
|
+
@content_type = args[:content_type] || 'text/html; charset=UTF-8;'
|
27
|
+
@template = Template.new(args[:template], @content_type)
|
28
|
+
@subject = @template.subject || args[:subject]
|
29
|
+
@serv = []; args[:servers].each {|s| @serv << @servers[s][0][:values] }
|
30
|
+
setup_server(@serv[0])
|
31
|
+
end
|
32
|
+
attr_accessor :list, :from, :content_type, :subject, :serv
|
33
|
+
|
34
|
+
def self.start(file, &block)
|
35
|
+
self.new(file)
|
36
|
+
block.call(self) if block_given?
|
37
|
+
end
|
38
|
+
|
39
|
+
def send
|
40
|
+
@list.each {|p| connect p[:email], generate_email(p) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def send_block(bloc = 1, rest = nil, &block)
|
44
|
+
j = 0
|
45
|
+
while (j <= @list.size) do
|
46
|
+
@list[j..(j = until_this(j,bloc))].each {|p| connect p[:email], generate_email(p)}
|
47
|
+
sleep(rest) if rest
|
48
|
+
block.call(self) if block_given?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def send_to_random_servers(bloc = 1, rest = 0)
|
53
|
+
send_block bloc, rest { setup_server(@serv[rand(@serv.size)]) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def send_to_servers
|
57
|
+
@v = 0
|
58
|
+
send_block bloc, rest { setup_server(@serv[(@v += 1) % @serv.size]) }
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def until_this(j, block)
|
63
|
+
j + bloc > @list.size ? j + bloc : @list.size
|
64
|
+
end
|
65
|
+
|
66
|
+
def generate_email(data)
|
67
|
+
@template.generate_email(data)
|
68
|
+
end
|
69
|
+
|
70
|
+
def setup_server(server)
|
71
|
+
Mail.defaults { delivery_method :smtp, server }
|
72
|
+
end
|
73
|
+
|
74
|
+
def connect(email, template)
|
75
|
+
#begin
|
76
|
+
mail = Mail.new
|
77
|
+
mail.to email
|
78
|
+
mail.from @from
|
79
|
+
mail.subject @subject
|
80
|
+
mail.text_part do
|
81
|
+
body 'This mail should be rendered or viewed as HTML'
|
82
|
+
end
|
83
|
+
mail.html_part do
|
84
|
+
content_type 'text/html; charset=UTF-8'
|
85
|
+
body template
|
86
|
+
end
|
87
|
+
@attach.each do |file|
|
88
|
+
m.add_file file
|
89
|
+
end
|
90
|
+
mail.deliver
|
91
|
+
|
92
|
+
D "Successfully sent #{email}"
|
93
|
+
#m = Mail.new
|
94
|
+
#m.to email
|
95
|
+
#m.from @from
|
96
|
+
#m.subject @subject
|
97
|
+
#m.content_type @content_type
|
98
|
+
#if @template.is_text?
|
99
|
+
# m.text_part { body template }
|
100
|
+
#end
|
101
|
+
#if @template.is_html?
|
102
|
+
# m.html_part do
|
103
|
+
# content_type @content_type
|
104
|
+
# body template
|
105
|
+
# end
|
106
|
+
#end
|
107
|
+
#@attach.each do |file|
|
108
|
+
# m.add_file file
|
109
|
+
#end
|
110
|
+
#m.deliver
|
111
|
+
#D "Successfully sent #{email}"
|
112
|
+
#rescue
|
113
|
+
# D "Something went wrong sending #{email}"
|
114
|
+
#end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
#
|
3
|
+
# {:address => "smtp.me.com",
|
4
|
+
# :port => 587,
|
5
|
+
# :domain => 'your.host.name',
|
6
|
+
# :user_name => '<username>',
|
7
|
+
# :password => '<password>',
|
8
|
+
# :authentication => 'plain',
|
9
|
+
# :enable_starttls_auto => true}
|
10
|
+
#
|
11
|
+
module EMaily
|
12
|
+
class Servers
|
13
|
+
SERVERS_PATH = ENV["HOME"] + "/.emaily_servers"
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
File.exist?(SERVERS_PATH) ? @servers = YAML.load_file(SERVERS_PATH) : @servers = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(name, values = {})
|
20
|
+
@servers << {:name => name, :values => values }
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(arg)
|
24
|
+
@servers.delete_if {|x| x[:name] == arg }
|
25
|
+
end
|
26
|
+
|
27
|
+
def select_server(arg)
|
28
|
+
@servers.select {|x| x[:name] == arg}
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](arg)
|
32
|
+
select_server(arg)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.load
|
36
|
+
self.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def flush
|
40
|
+
File.open(SERVERS_PATH, 'w') { |f| f.puts(YAML::dump(@servers)) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# I wish there was a good API for this. ARGH !!!!
|
2
|
+
|
3
|
+
module EMaily
|
4
|
+
class SkyDrive
|
5
|
+
LOGIN_URI = "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1242028992&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fskydrive.live.com%2Fwelcome.aspx%3Fmkt%3Den-us&lc=1033&id=250206&mkt=en-US"
|
6
|
+
def initialize
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def login(username,password)
|
11
|
+
#TBI
|
12
|
+
end
|
13
|
+
|
14
|
+
def upload(files)
|
15
|
+
files.each do |file|
|
16
|
+
#TBI
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
####
|
2
|
+
#### Values in templates are represented by %%value%%.
|
3
|
+
#### for example %%name%%
|
4
|
+
####
|
5
|
+
|
6
|
+
module EMaily
|
7
|
+
class Template
|
8
|
+
def initialize(template, content_type)
|
9
|
+
file = File.readlines(template)
|
10
|
+
if file[0].match(/<subject>/)
|
11
|
+
@s = file[0].scan(/<subject>(.*)<\/subject>/)[0][0]
|
12
|
+
@t=file[1..-1].to_s
|
13
|
+
else
|
14
|
+
@t = file.to_s
|
15
|
+
end
|
16
|
+
@c = content_type
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_email(values)
|
20
|
+
email=@t
|
21
|
+
D "Creating Email for #{values[:email]}" if values[:email]
|
22
|
+
@t.scan(/(%%.*%%)/).each {|x| email.gsub!(/(#{x[0]})/) {|s| values[s.to_s[2...-2].to_sym]}}
|
23
|
+
email
|
24
|
+
end
|
25
|
+
|
26
|
+
def is_text?
|
27
|
+
@c.match(/text\/plain/) != nil ? true : false
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_html?
|
31
|
+
@c.match(/text\/html/) != nil ? true : false
|
32
|
+
end
|
33
|
+
|
34
|
+
def subject
|
35
|
+
@s || nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: emaily
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matias P. Brutti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-25 00:00:00 -03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mail
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.2
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: matiasbrutti@gmail.com
|
27
|
+
executables:
|
28
|
+
- emaily
|
29
|
+
- emaily_genlist
|
30
|
+
- qp_decoder
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README
|
35
|
+
files:
|
36
|
+
- lib/emaily/csv.rb
|
37
|
+
- lib/emaily/emaily.rb
|
38
|
+
- lib/emaily/servers.rb
|
39
|
+
- lib/emaily/skydrive.rb
|
40
|
+
- lib/emaily/templates.rb
|
41
|
+
- lib/emaily/webserver.rb
|
42
|
+
- lib/emaily.rb
|
43
|
+
- templates/test_template.html
|
44
|
+
- README
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://freedomcoder.com.ar/emaily
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: A library to send template to multiple emails.
|
73
|
+
test_files: []
|
74
|
+
|