ydim 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -5
- data/History.txt +4 -0
- data/Rakefile +11 -0
- data/get_db_ydim +29 -0
- data/lib/ydim/mail.rb +45 -78
- data/lib/ydim/version.rb +1 -1
- data/test/test_item.rb +1 -1
- data/test/test_mail.rb +21 -23
- data/ydim.gemspec +1 -1
- data/{bin/migrate_to_utf_8 → ydim_migrate_to_utf_8} +7 -33
- metadata +6 -8
- data/lib/ydim/smtp_tls.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 878732dac4f51ff26346c7392d8241feb891cf28
|
4
|
+
data.tar.gz: dccb435ce281b6174843f75530288557d45c30f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84c88d7a0921fec44fbed80751e077a26138b2d8260251a83aaf3ae5e7a2418eebd96b7187d7a1af228557fa4f44eded00848c80927e787fca94fcd68dad886f
|
7
|
+
data.tar.gz: 2cfe94ce46a6dcba53096d3a596b54fe1067ac5dae6d2d110292921228779c63a3814ab6dcb0327ec8a3b2cdb3ffbe183768e65255360fdc9bc116e76db5a3b0
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -16,6 +16,17 @@ task :gem => :build do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
task :spec => :clean
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
task :default => [:clobber, :test, :gem]
|
22
|
+
|
23
|
+
dir = File.dirname(__FILE__)
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.libs << 'test'
|
26
|
+
t.test_files = Dir.glob("#{dir}/test/suite.rb")
|
27
|
+
t.warning = false
|
28
|
+
t.verbose = false
|
29
|
+
end
|
19
30
|
|
20
31
|
require 'rake/clean'
|
21
32
|
CLEAN.include FileList['pkg/*.gem']
|
data/get_db_ydim
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/bin/bash -v
|
2
|
+
set -x
|
3
|
+
DB_NAME=ydim
|
4
|
+
|
5
|
+
yyyy=`date -d '1 days ago' +"%Y"`
|
6
|
+
mm=`date -d '1 days ago' +"%m"`
|
7
|
+
dd=`date -d '1 days ago' +"%d"`
|
8
|
+
DB_DUMP=/var/backup/fast/db_dumps/${DB_NAME}.$yyyy$mm$dd.sql.gz
|
9
|
+
|
10
|
+
|
11
|
+
m=(dummy January February March April May June July August September October November December)
|
12
|
+
nm=`expr $mm + 0`
|
13
|
+
cd /var/backup/fast/db_dumps/
|
14
|
+
cmd="scp ywesee@ywesee.com:/var/backup/thinpower/db/postgresql/${m[nm]}-$yyyy/$yyyy-$mm-$dd/22\:00-postgresql_database-${DB_NAME}-backup.gz ${DB_NAME}.$yyyy$mm$dd.sql.gz"
|
15
|
+
echo Calling $cmd
|
16
|
+
$cmd
|
17
|
+
ls -l $DB_DUMP
|
18
|
+
sudo -u postgres dropdb $DB_NAME
|
19
|
+
|
20
|
+
sudo -u postgres createdb -E UTF8 -T template0 $DB_NAME
|
21
|
+
if [ $? -ne 0 ] ; then exit 1; fi
|
22
|
+
if [ ! -f $DB_DUMP ]
|
23
|
+
then
|
24
|
+
echo "Cannot find $DB_DUMP. Have look at the get_db_dumps.rb script or get it directly from"
|
25
|
+
exit 1
|
26
|
+
fi
|
27
|
+
|
28
|
+
zcat $DB_DUMP | sudo -u postgres psql $DB_NAME
|
29
|
+
if [ $? -ne 0 ] ; then exit 1; fi
|
data/lib/ydim/mail.rb
CHANGED
@@ -1,51 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Mail -- ydim -- 18.01.2006 -- hwyss@ywesee.com
|
3
2
|
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require 'ydim/smtp_tls'
|
3
|
+
require 'ydim/server' # to pick up the configuration
|
4
|
+
require 'mail'
|
7
5
|
|
8
6
|
module YDIM
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
header.add('Content-Disposition', 'attachment', nil,
|
37
|
-
{'filename' => invoice_name })
|
38
|
-
header.add('Content-Transfer-Encoding', 'base64')
|
39
|
-
fpart.body = [invoice.to_pdf(sort_args)].pack('m')
|
40
|
-
recipients = config.mail_recipients.dup.push(to).concat(cc).uniq
|
41
|
-
Net::SMTP.start(config.smtp_server, config.smtp_port,
|
42
|
-
config.smtp_domain, config.smtp_user, config.smtp_pass,
|
43
|
-
config.smtp_authtype) { |smtp|
|
44
|
-
recipients.each { |recipient|
|
45
|
-
smtp.sendmail(mpart.to_s, config.smtp_user, recipient)
|
46
|
-
}
|
47
|
-
}
|
48
|
-
recipients
|
7
|
+
module Mail
|
8
|
+
::Mail.defaults do
|
9
|
+
delivery_method :smtp, {
|
10
|
+
:address => Server.config.smtp_server,
|
11
|
+
:port => Server.config.smtp_port,
|
12
|
+
:domain => Server.config.smtp_domain,
|
13
|
+
:user_name => Server.config.smtp_user,
|
14
|
+
:password => Server.config.smtp_pass,
|
15
|
+
}
|
16
|
+
end
|
17
|
+
def Mail.body(config, debitor, invoice)
|
18
|
+
salutation = config.salutation[debitor.salutation.to_s]
|
19
|
+
sprintf(config.mail_body, salutation, debitor.contact, invoice.description)
|
20
|
+
end
|
21
|
+
def Mail.send_invoice(config, invoice, sort_args={})
|
22
|
+
debitor = invoice.debitor
|
23
|
+
invoice_subject = sprintf('Rechnung %s #%i, %s', debitor.name,
|
24
|
+
invoice.unique_id, invoice.description)
|
25
|
+
@mail = ::Mail.new
|
26
|
+
@mail.to = debitor.email
|
27
|
+
@mail.cc = debitor.emails_cc
|
28
|
+
@mail.from = config.mail_from
|
29
|
+
@mail.subject = invoice_subject
|
30
|
+
@mail.body = body(config, debitor, invoice)
|
31
|
+
@mail.attachments['myfile.pdf'] = { :mime_type => 'application/x-pdf',
|
32
|
+
:content => invoice.to_pdf(sort_args) }
|
33
|
+
@mail.deliver
|
49
34
|
rescue Timeout::Error
|
50
35
|
retries ||= 3
|
51
36
|
if retries > 0
|
@@ -55,41 +40,23 @@ module YDIM
|
|
55
40
|
else
|
56
41
|
raise
|
57
42
|
end
|
58
|
-
|
43
|
+
end
|
59
44
|
def Mail.send_reminder(config, autoinvoice)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
header.date = Time.now
|
76
|
-
header.add('Content-Type', 'text/plain', nil,
|
77
|
-
'charset' => config.mail_charset)
|
78
|
-
mpart.body = body
|
79
|
-
recipients = config.mail_recipients.dup.push(to).concat(cc).uniq
|
80
|
-
Net::SMTP.start(config.smtp_server, config.smtp_port,
|
81
|
-
config.smtp_domain, config.smtp_user, config.smtp_pass,
|
82
|
-
config.smtp_authtype) { |smtp|
|
83
|
-
recipients.each { |recipient|
|
84
|
-
smtp.sendmail(mpart.to_s, config.smtp_user, recipient)
|
85
|
-
}
|
86
|
-
}
|
87
|
-
recipients
|
88
|
-
end
|
89
|
-
end
|
90
|
-
def Mail.encode_subject(config, subject)
|
91
|
-
encoded = [subject].pack('M').gsub("=\n", '').gsub(' ', '=20')
|
92
|
-
sprintf("=?%s?q?%s?=", config.mail_charset, encoded)
|
45
|
+
debitor = autoinvoice.debitor
|
46
|
+
reminder_subject = autoinvoice.reminder_subject.to_s.strip
|
47
|
+
reminder_subject.gsub! %r{<year>\s*}, ''
|
48
|
+
reminder_subject.gsub! %r{\s*</year>}, ''
|
49
|
+
mail_body = autoinvoice.reminder_body.to_s.strip
|
50
|
+
mail_body.gsub! %r{<invoice>\s*}, ''
|
51
|
+
mail_body.gsub! %r{\s*</invoice>}, ''
|
52
|
+
return if reminder_subject.empty? || mail_body.empty?
|
53
|
+
@mail = ::Mail.new
|
54
|
+
@mail.to = debitor.email
|
55
|
+
@mail.cc = debitor.emails_cc
|
56
|
+
@mail.from = config.mail_from
|
57
|
+
@mail.subject = reminder_subject
|
58
|
+
@mail.body = mail_body
|
59
|
+
@mail.deliver
|
93
60
|
end
|
94
61
|
end
|
95
62
|
end
|
data/lib/ydim/version.rb
CHANGED
data/test/test_item.rb
CHANGED
data/test/test_mail.rb
CHANGED
@@ -6,10 +6,15 @@ $: << File.expand_path('../lib', File.dirname(__FILE__))
|
|
6
6
|
require 'minitest/autorun'
|
7
7
|
require 'flexmock/test_unit'
|
8
8
|
require 'ydim/mail'
|
9
|
-
|
10
9
|
module YDIM
|
11
10
|
class TestMail < Minitest::Test
|
12
11
|
include FlexMock::TestCase
|
12
|
+
def setup
|
13
|
+
::Mail.defaults do
|
14
|
+
delivery_method :test
|
15
|
+
end
|
16
|
+
::Mail::TestMailer.deliveries.clear
|
17
|
+
end
|
13
18
|
def setup_config
|
14
19
|
config = flexmock('Config')
|
15
20
|
config.should_receive(:mail_body).and_return <<-MAIL
|
@@ -42,11 +47,12 @@ module YDIM
|
|
42
47
|
debitor.should_receive(:contact).and_return('Melanie Esterhazy')
|
43
48
|
invoice = flexmock('Invoice')
|
44
49
|
invoice.should_receive(:description).and_return('Description')
|
45
|
-
|
46
|
-
|
47
|
-
Sehr geehrte Frau Melanie Esterhazy
|
50
|
+
assert_equal(0, ::Mail::TestMailer.deliveries.size)
|
51
|
+
res = Mail.body(setup_config, debitor, invoice)
|
52
|
+
expected = %( Sehr geehrte Frau Melanie Esterhazy
|
48
53
|
Description
|
49
|
-
|
54
|
+
)
|
55
|
+
assert_equal(expected, res)
|
50
56
|
end
|
51
57
|
def test_send_invoice
|
52
58
|
debitor = flexmock('Debitor')
|
@@ -60,16 +66,13 @@ module YDIM
|
|
60
66
|
invoice.should_receive(:unique_id).and_return(12345)
|
61
67
|
invoice.should_receive(:description).and_return('Description')
|
62
68
|
invoice.should_receive(:to_pdf).times(1).and_return('pdf-document')
|
63
|
-
|
64
|
-
flexstub(Net::SMTP).should_receive(:new).and_return(smtp)
|
65
|
-
smtp.should_receive(:start)
|
66
|
-
smtp.should_receive(:sendmail).with(String,
|
67
|
-
'smtp@ywesee.com', 'cc@ywesee.com').and_return { assert(true) }
|
68
|
-
smtp.should_receive(:sendmail).with(String,
|
69
|
-
'smtp@ywesee.com', 'test@ywesee.com').and_return { assert(true) }
|
70
|
-
smtp.should_receive(:sendmail).with(String,
|
71
|
-
'smtp@ywesee.com', 'test.cc@ywesee.com').and_return { assert(true) }
|
69
|
+
assert_equal(0, ::Mail::TestMailer.deliveries.size)
|
72
70
|
Mail.send_invoice(setup_config, invoice)
|
71
|
+
assert_equal(1, ::Mail::TestMailer.deliveries.size)
|
72
|
+
assert_equal(" Sehr geehrter Herr Contact-Name\n" +
|
73
|
+
" Description\n",
|
74
|
+
::Mail::TestMailer.deliveries.first.body.to_s)
|
75
|
+
assert_equal('Rechnung Company-Name #12345, Description', ::Mail::TestMailer.deliveries.first.subject)
|
73
76
|
end
|
74
77
|
def test_send_reminder
|
75
78
|
debitor = flexmock('Debitor')
|
@@ -84,16 +87,11 @@ module YDIM
|
|
84
87
|
invoice.should_receive(:description).and_return('Description')
|
85
88
|
invoice.should_receive(:reminder_subject).and_return('Reminder')
|
86
89
|
invoice.should_receive(:reminder_body).and_return('Reminder Body')
|
87
|
-
|
88
|
-
flexstub(Net::SMTP).should_receive(:new).and_return(smtp)
|
89
|
-
smtp.should_receive(:start)
|
90
|
-
smtp.should_receive(:sendmail).with(String,
|
91
|
-
'smtp@ywesee.com', 'cc@ywesee.com').and_return { assert(true) }
|
92
|
-
smtp.should_receive(:sendmail).with(String,
|
93
|
-
'smtp@ywesee.com', 'test@ywesee.com').and_return { assert(true) }
|
94
|
-
smtp.should_receive(:sendmail).with(String,
|
95
|
-
'smtp@ywesee.com', 'test.cc@ywesee.com').and_return { assert(true) }
|
90
|
+
assert_equal(0, ::Mail::TestMailer.deliveries.size)
|
96
91
|
Mail.send_reminder(setup_config, invoice)
|
92
|
+
assert_equal(1, ::Mail::TestMailer.deliveries.size)
|
93
|
+
assert_equal("Reminder Body", ::Mail::TestMailer.deliveries.first.body.to_s)
|
94
|
+
assert_equal('Reminder', ::Mail::TestMailer.deliveries.first.subject)
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
data/ydim.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "ydbd-pg", '>= 0.5.1'
|
22
22
|
spec.add_dependency "ydbi", '>= 0.5.1'
|
23
23
|
spec.add_dependency "syck"
|
24
|
-
spec.add_dependency "
|
24
|
+
spec.add_dependency "mail"
|
25
25
|
spec.add_dependency "rclconf"
|
26
26
|
spec.add_dependency "needle"
|
27
27
|
spec.add_dependency "ypdf-writer"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
#encoding: ASCII-8BIT
|
3
3
|
puts "#{Time.now}: Loading #{__FILE__}"
|
4
4
|
STDOUT.sync = true
|
5
5
|
|
@@ -150,43 +150,17 @@ module YDIM
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
|
154
|
-
@logger
|
153
|
+
@logger = Logger.new("/tmp/#{File.basename(__FILE__)}.log")
|
154
|
+
@logger.info "#{Time.now}: Calling #{File.basename(__FILE__)}"
|
155
155
|
@logger.level = Logger::DEBUG
|
156
156
|
config = YDIM::Server.config
|
157
|
+
@logger.info "user: #{config.db_user} auth: #{config.db_auth}"
|
157
158
|
|
158
|
-
ODBA.storage.dbi = ODBA::ConnectionPool.new(config.db_driver_url,
|
159
|
-
config.db_user, config.db_auth, :client_encoding => 'LATIN1')
|
159
|
+
ODBA.storage.dbi = ODBA::ConnectionPool.new(config.db_driver_url, config.db_user, config.db_auth, :client_encoding => 'LATIN1')
|
160
160
|
ODBA.cache.setup
|
161
161
|
|
162
162
|
DRb.install_id_conv ODBA::DRbIdConv.new
|
163
163
|
|
164
|
-
if false
|
165
|
-
server = YDIM::Server.new(config, logger)
|
166
|
-
server.extend(DRbUndumped)
|
167
|
-
|
168
|
-
puts config.inspect
|
169
|
-
if(config.detach)
|
170
|
-
pidfile = '/var/run/ydimd.pid'
|
171
|
-
File.open(pidfile, 'w') { |fh| fh.puts $$ }
|
172
|
-
at_exit { File.unlink(pidfile) }
|
173
|
-
Process.fork and exit!(0)
|
174
|
-
end
|
175
|
-
|
176
|
-
begin
|
177
|
-
url = config.server_url
|
178
|
-
url.untaint
|
179
|
-
DRb.start_service(url, server)
|
180
|
-
$SAFE = 1
|
181
|
-
logger.info('start') {
|
182
|
-
sprintf("starting ydim-server on %s", config.server_url) }
|
183
|
-
DRb.thread.join
|
184
|
-
rescue Exception => error
|
185
|
-
logger.error('fatal') { error }
|
186
|
-
raise
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
164
|
@server = YDIM::Server.new(config, @logger)
|
191
165
|
@server.extend(DRbUndumped)
|
192
166
|
session = YDIM::RootSession.new(YDIM::RootUser.new(1))
|
@@ -195,7 +169,7 @@ session.serv = @server
|
|
195
169
|
:invoices => session.invoices,
|
196
170
|
:debitors => session.debitors,
|
197
171
|
}.each do |name, to_migrate|
|
198
|
-
puts "#{Time.now}: Start migrating #{name}"
|
172
|
+
puts "#{Time.now}: Start migrating #{to_migrate.size} #{name}"
|
199
173
|
@server._migrate_to_utf8(to_migrate, {})
|
200
174
|
end
|
201
|
-
|
175
|
+
@logger.info "#{Time.now}: Finished #{File.basename(__FILE__)}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ydim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: odba
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: mail
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -265,7 +265,6 @@ dependencies:
|
|
265
265
|
description: ywesee distributed invoice manager. A Ruby gem
|
266
266
|
email: mhatakeyama@ywesee.com, zdavatz@ywesee.com, ngiger@ywesee.com
|
267
267
|
executables:
|
268
|
-
- migrate_to_utf_8
|
269
268
|
- ydim-edit
|
270
269
|
- ydim-inject
|
271
270
|
- ydimd
|
@@ -280,10 +279,10 @@ files:
|
|
280
279
|
- LICENSE.txt
|
281
280
|
- Manifest.txt
|
282
281
|
- Rakefile
|
283
|
-
- bin/migrate_to_utf_8
|
284
282
|
- bin/ydim-edit
|
285
283
|
- bin/ydim-inject
|
286
284
|
- bin/ydimd
|
285
|
+
- get_db_ydim
|
287
286
|
- install.rb
|
288
287
|
- lib/pdfinvoice/config.rb
|
289
288
|
- lib/pdfinvoice/invoice.rb
|
@@ -301,7 +300,6 @@ files:
|
|
301
300
|
- lib/ydim/root_session.rb
|
302
301
|
- lib/ydim/root_user.rb
|
303
302
|
- lib/ydim/server.rb
|
304
|
-
- lib/ydim/smtp_tls.rb
|
305
303
|
- lib/ydim/util.rb
|
306
304
|
- lib/ydim/version.rb
|
307
305
|
- lib/ydim/ydim-edit
|
@@ -326,6 +324,7 @@ files:
|
|
326
324
|
- test/test_root_user.rb
|
327
325
|
- test/test_server.rb
|
328
326
|
- ydim.gemspec
|
327
|
+
- ydim_migrate_to_utf_8
|
329
328
|
homepage: https://github.com/zdavatz/ydim
|
330
329
|
licenses:
|
331
330
|
- GPL-v2
|
@@ -346,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
346
345
|
version: '0'
|
347
346
|
requirements: []
|
348
347
|
rubyforge_project:
|
349
|
-
rubygems_version: 2.
|
348
|
+
rubygems_version: 2.6.8
|
350
349
|
signing_key:
|
351
350
|
specification_version: 4
|
352
351
|
summary: ywesee distributed invoice manager
|
@@ -367,4 +366,3 @@ test_files:
|
|
367
366
|
- test/test_root_session.rb
|
368
367
|
- test/test_root_user.rb
|
369
368
|
- test/test_server.rb
|
370
|
-
has_rdoc:
|
data/lib/ydim/smtp_tls.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require "openssl"
|
2
|
-
require "net/smtp"
|
3
|
-
|
4
|
-
Net::SMTP.class_eval do
|
5
|
-
private
|
6
|
-
def do_start(helodomain, user, secret, authtype)
|
7
|
-
raise IOError, 'SMTP session already started' if @started
|
8
|
-
check_auth_args user, secret, authtype if user or secret
|
9
|
-
|
10
|
-
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
|
11
|
-
@socket = Net::InternetMessageIO.new(sock)
|
12
|
-
@socket.read_timeout = 60 #@read_timeout
|
13
|
-
@socket.debug_output = STDERR #@debug_output
|
14
|
-
|
15
|
-
check_response(critical { recv_response() })
|
16
|
-
do_helo(helodomain)
|
17
|
-
|
18
|
-
raise 'openssl library not installed' unless defined?(OpenSSL)
|
19
|
-
starttls
|
20
|
-
ssl = OpenSSL::SSL::SSLSocket.new(sock)
|
21
|
-
ssl.sync_close = true
|
22
|
-
ssl.connect
|
23
|
-
@socket = Net::InternetMessageIO.new(ssl)
|
24
|
-
@socket.read_timeout = 60 #@read_timeout
|
25
|
-
@socket.debug_output = STDERR #@debug_output
|
26
|
-
do_helo(helodomain)
|
27
|
-
|
28
|
-
authenticate user, secret, authtype if user
|
29
|
-
@started = true
|
30
|
-
ensure
|
31
|
-
unless @started
|
32
|
-
# authentication failed, cancel connection.
|
33
|
-
@socket.close if not @started and @socket and not @socket.closed?
|
34
|
-
@socket = nil
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def do_helo(helodomain)
|
39
|
-
begin
|
40
|
-
if @esmtp
|
41
|
-
ehlo helodomain
|
42
|
-
else
|
43
|
-
helo helodomain
|
44
|
-
end
|
45
|
-
rescue Net::ProtocolError
|
46
|
-
if @esmtp
|
47
|
-
@esmtp = false
|
48
|
-
@error_occured = false
|
49
|
-
retry
|
50
|
-
end
|
51
|
-
raise
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def starttls
|
56
|
-
getok('STARTTLS')
|
57
|
-
end
|
58
|
-
end
|