From 7083c7e2fcd1a34b0d3466381e68cc94f6da58f8 Mon Sep 17 00:00:00 2001
From: jsabban <jules.sabban@inrae.fr>
Date: Thu, 9 Sep 2021 11:23:04 +0200
Subject: [PATCH] Add basic email sending command #5

---
 main.nf | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/main.nf b/main.nf
index 2c7e27c..08e3abf 100644
--- a/main.nf
+++ b/main.nf
@@ -348,8 +348,12 @@ workflow.onComplete {
     // Send the HTML e-mail
     if (email_address) {
       // Catch failures and try with plaintext
-      [ 'mail', '-s', subject, email_address ].execute() << email_txt
-      log.info "[$name_wf] Sent summary e-mail to $email_address (mail)"
+	  try {
+		  def sending = [ 'echo', '-e' , email_txt ].execute() | [ 'mail', '-s', subject, email_address  ].execute()
+		  log.debug "[$name_wf] Sent summary e-mail to $email_address (mail)"
+	  } catch (all) {
+		  log.error "[$name_wf] ERROR ON EMAIL SENDING TO $email_address !!"
+	  }
       log.info "$email_txt"
     }
 
-- 
GitLab