On Wed, Dec 02, 2020 at 09:43:45AM +0800, Xiao Shenwei wrote:
On Wed, Dec 02, 2020 at 09:37:42AM +0800, Luan Shengde wrote:
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|
use %Y%m%d%H%M%S a large number of small files are generated?
how about unit: hour or day, use append mode
it works no need to change
Thanks, Luan Shengde
Thanks, Shenwei
- f.puts mail
- end
- FileUtils.chown_R(1144, 1110, file_full_name)
+end
2.23.0