mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 19:13:06 +07:00
main: format
This commit is contained in:
parent
6e749a80b9
commit
445b6879ac
28
main.rb
28
main.rb
@ -4,29 +4,29 @@
|
|||||||
require 'net/smtp'
|
require 'net/smtp'
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
address = ENV["INPUT_SERVER_ADDRESS"]
|
address = ENV['INPUT_SERVER_ADDRESS']
|
||||||
port = ENV["INPUT_SERVER_PORT"]
|
port = ENV['INPUT_SERVER_PORT']
|
||||||
username = ENV["INPUT_USERNAME"]
|
username = ENV['INPUT_USERNAME']
|
||||||
password = ENV["INPUT_PASSWORD"]
|
password = ENV['INPUT_PASSWORD']
|
||||||
subject = ENV["INPUT_SUBJECT"]
|
subject = ENV['INPUT_SUBJECT']
|
||||||
body = ENV["INPUT_BODY"]
|
body = ENV['INPUT_BODY']
|
||||||
to = ENV["INPUT_TO"]
|
to = ENV['INPUT_TO']
|
||||||
from = ENV["INPUT_FROM"]
|
from = ENV['INPUT_FROM']
|
||||||
|
|
||||||
# Message
|
# Message
|
||||||
message = <<EOM
|
message = <<~END_OF_MESSAGE
|
||||||
Subject: #{subject}
|
Subject: #{subject}
|
||||||
From: #{from} <#{username}>
|
From: #{from} <#{username}>
|
||||||
|
|
||||||
#{body}
|
#{body}
|
||||||
EOM
|
END_OF_MESSAGE
|
||||||
|
|
||||||
# Send
|
# Send
|
||||||
begin
|
begin
|
||||||
smtp = Net::SMTP.new(address, port.to_i)
|
smtp = Net::SMTP.new(address, port.to_i)
|
||||||
smtp.enable_tls
|
smtp.enable_tls
|
||||||
smtp.start(address, username, password, :login)
|
smtp.start(address, username, password, :login)
|
||||||
smtp.send_message(message, username, to.split(","))
|
smtp.send_message(message, username, to.split(','))
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
puts "Error: #{e.message}"
|
puts "Error: #{e.message}"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user