set up smtp config for smtp.qq.com send mail with recieved email data
Signed-off-by: Luan Shengde luanshengde2@huawei.com --- .../send-internet-mail/send-internet-mail.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 container/send-internet-mail/send-internet-mail.rb
diff --git a/container/send-internet-mail/send-internet-mail.rb b/container/send-internet-mail/send-internet-mail.rb new file mode 100755 index 0000000..d8c8d64 --- /dev/null +++ b/container/send-internet-mail/send-internet-mail.rb @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'mail' + +# setup smtp config +smtp = { + address: 'smtp.qq.com', + port: 25, + domain: 'qq.com', + user_name: ENV['EMAIL_ADDRESS'], + password: ENV['EMAIL_PASSWORD'], + openssl_verify_mode: 'none', + enable_starttls_auto: true +} + +Mail.defaults { delivery_method :smtp, smtp } + +# send mail +def send_mail(mail_info) + mail = Mail.new do + references mail_info['references'] + from ENV['EMAIL_ADDRESS'] + subject mail_info['subject'] + to mail_info['to'] + body mail_info['body'] + end + mail.deliver! +end