setup smtp config for email server invoke mail-post to hand the send mail request
Signed-off-by: Luan Shengde luanshengde2@huawei.com --- container/send-mail/send-mail.rb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/container/send-mail/send-mail.rb b/container/send-mail/send-mail.rb index f459e78..436736c 100755 --- a/container/send-mail/send-mail.rb +++ b/container/send-mail/send-mail.rb @@ -4,25 +4,14 @@ # frozen_string_literal: true
require 'mail' +require 'sinatra' +require "#{ENV['CCI_SRC']}/lib/mail-post"
-mail_server = `/sbin/ip route |awk '/default/ {print $3}'`.chomp +mail_server = %x(/sbin/ip route |awk '/default/ {print $3}').chomp
-# setup smtp config smtp = { address: mail_server, enable_starttls_auto: false }
Mail.defaults { delivery_method :smtp, smtp } - -# send mail -def send_mail(mail_info) - mail = Mail.new do - references mail_info['references'] - from mail_info['from'] - subject mail_info['subject'] - to mail_info['to'] - body mail_info['body'] - end - mail.deliver! -end