Commit f389f78e authored by John Long's avatar John Long

Support multiple mailboxes incoming email check

parent 0f6f3f2b
...@@ -28,9 +28,13 @@ module SystemCheck ...@@ -28,9 +28,13 @@ module SystemCheck
private private
def try_connect_imap def try_connect_imap
imap = Net::IMAP.new(config[:host], port: config[:port], ssl: config[:ssl]) config.each do |mailbox|
imap.starttls if config[:start_tls] $stdout.puts "\nChecking #{mailbox[:email]}\n"
imap.login(config[:email], config[:password]) imap = Net::IMAP.new(mailbox[:host], port: mailbox[:port], ssl: mailbox[:ssl])
imap.starttls if mailbox[:start_tls]
imap.login(mailbox[:email], mailbox[:password])
$stdout.puts "Connected to #{mailbox[:email]}\n"
end
true true
rescue => error rescue => error
@error = error @error = error
...@@ -51,7 +55,7 @@ module SystemCheck ...@@ -51,7 +55,7 @@ module SystemCheck
erb.filename = mail_room_config_path erb.filename = mail_room_config_path
config_file = YAML.load(erb.result) config_file = YAML.load(erb.result)
config_file.dig(:mailboxes, 0) config_file.dig(:mailboxes)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment