:78 Function create_function() is deprecated [8192]

testing email capibilities

Marcelo Ponce [2019-08-24 20:47:09]
testing email capibilities
Filename
testing/RACS.config
testing/testemail.sh
diff --git a/testing/RACS.config b/testing/RACS.config
new file mode 100644
index 0000000..10bd885
--- /dev/null
+++ b/testing/RACS.config
@@ -0,0 +1 @@
+mponcec@gmail.com
diff --git a/testing/testemail.sh b/testing/testemail.sh
new file mode 100644
index 0000000..f1a75e4
--- /dev/null
+++ b/testing/testemail.sh
@@ -0,0 +1,48 @@
+#!/bin/bash -xv
+
+# Auxiliary set of extra functions used in other scripts of the RACS pipeline.
+#
+# Main functions included:
+#       - emailme(): function to notify the user by sending an email.
+#
+#########################
+
+
+emailme() {
+# function to send emails, uses 3 arguments:
+	# arg.1: subject
+	# arg.2: message
+	# arg.3: email address (optional) as it will attempt to read it from the "RACS.config" file
+
+	# file from where to read email address
+	configFile="RACS.config"
+
+	# if config.file is found will read target email address from there
+	[ -f $configFile ] && fromfile=`head $configFile` || fromfile=""
+	# otherwise attempt to use the 3rd argument
+	To=${3:-"$fromfile"}
+
+	# arg.1 = subject
+	Subject=$1
+
+	# arg.2 = message
+	Msg=$2
+
+	# detect mailer program
+	MAILER=`which mail`
+	# check whether there is an program for sending emails...
+	[[ -z "$MAILER" ]] && echo "An email server should be configured in this sever ($HOST) for this functionality to work!?"
+
+	# check that there is a emailer configured and fields of the email are not empty
+ 	if [ "$MAILER" != "" ] &&  [ "$To" != "" ] && [ "$Subject" != "" ] ;
+	then
+		# send email...
+		echo "POS: " $MAILER $Subject $To
+		echo "hello world" | $MAILER -s $Subject $To
+	else
+		echo "neg: " $MAILER $Subject $To
+	fi
+}
+
+
+emailme test
ViewGit