On Mon, Nov 30, 2020 at 12:33:49PM +0800, Wu Fengguang wrote:
It should be a general feature on the /send_mail_text server side. All out emails should be stored, not just this call site.
OK, I will add this feature to the send-internet-mail service.
Thanks, Luan Shengde
On Mon, Nov 30, 2020 at 11:55:25AM +0800, Luan Shengde wrote:
[why] backup email file for successfully applied account
[how] backup email after build email message for successfully applied account
Signed-off-by: Luan Shengde shdluan@163.com
container/mail-robot/lib/apply-account.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/container/mail-robot/lib/apply-account.rb b/container/mail-robot/lib/apply-account.rb index bf40429..2d5631d 100755 --- a/container/mail-robot/lib/apply-account.rb +++ b/container/mail-robot/lib/apply-account.rb @@ -98,12 +98,23 @@ class ApplyAccount es.put_source_by_id(@my_info['my_email'], @my_info) end
- def store_email(email_message)
- time_now = Time.new.strftime('%Y%m%d%H%M%S')
- file_name = [@my_info['my_email'], time_now].join '_'
- file_full_name = File.join(MAILDIR, 'sent', file_name)
sent => .sent
Better further classify different type of emails to different folders.
- f = File.new(file_full_name, 'w')
- f.puts email_message
- f.close
- FileUtils.chown_R(1144, 1110, file_full_name)
chown_R -- do we need recursive?
Thanks, Fengguang
- end
- def send_mail(error_message)
- email_message = if error_message.empty?
build_apply_account_email(@my_info)
else
build_apply_account_fail_email(@my_info, error_message)
end
if error_message.empty?
email_message = build_apply_account_email(@my_info)
store_email(email_message)
else
email_message = build_apply_account_fail_email(@my_info, error_message)
end
%x(curl -XPOST "#{@send_mail_host}:#{@send_mail_port}/send_mail_text" -d "#{email_message}") end
-- 2.23.0