add function: store_email store email to MAILDIR/sent file name: ${email_addr}_${time_now}
Signed-off-by: Luan Shengde shdluan@163.com --- container/send-internet-mail/send-internet-mail.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) mode change 100644 => 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 old mode 100644 new mode 100755 index 3b1d159..851904c --- a/container/send-internet-mail/send-internet-mail.rb +++ b/container/send-internet-mail/send-internet-mail.rb @@ -19,3 +19,13 @@ smtp = { }
Mail.defaults { delivery_method :smtp, smtp } + +def store_email(mail) + time_now = Time.new.strftime('%Y%m%d%H%M%S') + file_name = [mail.to[0], time_now].join('_') + file_full_name = File.join(ENV['MAILDIR'], 'sent', file_name) + File.open(file_full_name, 'w') do |f| + f.puts mail + end + FileUtils.chown_R(1144, 1110, file_full_name) +end