
+ +def check_send_mail(mail_info) + if ENV['SMTP_REGION'] == 'internet-smtp'
Perhaps no need to test that. Just use
mail_info['from'] ||= ENV['FROM_ADDRESS']
And let the 2 containers pass different FROM_ADDRESS env into docker.
for send internet mail, the FROM_ADDRESS must be same to the user_name setted in smtp for send intranet mail, the FROM_ADDRESS can be either user defined or default setted. so if send internet mail the FROM_ADDRESS must be resetted, and if send intranet mail, the FROM_ADDRESS use user defined or a default value, and user defined value has high priority.
+ mail_info['from'] = ENV['ROBOT_EMAIL_ADDRESS'] + else + mail_info['from'] = ENV['ROBOT_EMAIL_ADDRESS'] if mail_info['from'].nil? + end + + raise 'no subject.' if mail_info['subject'].nil? + raise 'no email address.' if mail_info['to'].nil? + raise 'no email content.' if mail_info['body'].nil? + + send_mail(mail_info) +end + +def send_mail(mail_info) + setup_smtp
Can define the local version setup_smtp() here. And let the internet version override it.
do you mean: define a function setup_smtp for send intranet mail? define a function setup_smtp_internet for send internet mail in lib/internet-smtp.rb? default run setup_smtp? run setup_smtp_internet ENV['SMTP_REGION'] == 'internet-smtp'? Thanks Luan Shengde
Thanks, Fengguang
+ 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 -- 2.23.0