From ffd3aa467e0d37b4d30adc9508a0c85953324d47 Mon Sep 17 00:00:00 2001 From: Joshua Greben Date: Thu, 16 Nov 2023 13:59:04 -0800 Subject: [PATCH] Fix email config --- tasks/download_report.rake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tasks/download_report.rake b/tasks/download_report.rake index 5d190b4..a3be9d7 100644 --- a/tasks/download_report.rake +++ b/tasks/download_report.rake @@ -23,18 +23,18 @@ task :mail do delivery_method :smtp, options end - file = File.read('files/credits.csv') - - file.write('NO FILE') unless file.file? - - mail = Mail.new do - from 'cardPaymentReporter@stanford.edu' - to ENV.fetch('EMAIL_REPORT_TO', 'sul-unicorn-devs@lists.stanford.edu') - subject "Card Payment Report #{Date.today.strftime('%m-%Y')}" - body File.read(file) - add_file file + begin + mail = Mail.new do + from 'cardPaymentReporter@stanford.edu' + to ENV.fetch('EMAIL_REPORT_TO', 'sul-unicorn-devs@lists.stanford.edu') + subject "Card Payment Report #{Date.today.strftime('%m-%Y')}" + body File.read('files/credits.csv') + add_file 'files/credits.csv' + end + + mail.delivery_method :sendmail + mail.deliver + rescue Errno::ENOENT => e + puts e end - - mail.delivery_method :sendmail - mail.deliver end