main: format

This commit is contained in:
Dawid Dziurla 2019-12-06 10:18:17 +01:00
parent 6e749a80b9
commit 445b6879ac
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B

28
main.rb
View File

@ -4,29 +4,29 @@
require 'net/smtp'
# Inputs
address = ENV["INPUT_SERVER_ADDRESS"]
port = ENV["INPUT_SERVER_PORT"]
username = ENV["INPUT_USERNAME"]
password = ENV["INPUT_PASSWORD"]
subject = ENV["INPUT_SUBJECT"]
body = ENV["INPUT_BODY"]
to = ENV["INPUT_TO"]
from = ENV["INPUT_FROM"]
address = ENV['INPUT_SERVER_ADDRESS']
port = ENV['INPUT_SERVER_PORT']
username = ENV['INPUT_USERNAME']
password = ENV['INPUT_PASSWORD']
subject = ENV['INPUT_SUBJECT']
body = ENV['INPUT_BODY']
to = ENV['INPUT_TO']
from = ENV['INPUT_FROM']
# Message
message = <<EOM
Subject: #{subject}
From: #{from} <#{username}>
message = <<~END_OF_MESSAGE
Subject: #{subject}
From: #{from} <#{username}>
#{body}
EOM
#{body}
END_OF_MESSAGE
# Send
begin
smtp = Net::SMTP.new(address, port.to_i)
smtp.enable_tls
smtp.start(address, username, password, :login)
smtp.send_message(message, username, to.split(","))
smtp.send_message(message, username, to.split(','))
rescue StandardError => e
puts "Error: #{e.message}"
exit 1