setup smtp send mail with received email info
Signed-off-by: Luan Shengde luanshengde2@huawei.com --- .../send-internet-mail/send-internet-mail.rb | 33 +++++++++++++++++++ 1 file changed, 33 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..f0d7698 --- /dev/null +++ b/container/send-internet-mail/send-internet-mail.rb @@ -0,0 +1,33 @@ +#!/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: 'compass-ci@qq.com', + password: 'passwd for user_name', + # enable_ssl: true, + # authentication: :login, + 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 'compass-ci@qq.com' + to mail_info['to'] + subject mail_info['subject'] + body mail_info['body'] + end + mail.deliver! +end