#!/bin/bash


function get_error () {

IFS="
"
cat << EOF | grep -w ^$1
0 Success
1 Syntax or usage error
2 Protocol incompatibility
3 Errors selecting input/output files, dirs
4 Requested action not supported: an attempt was made  to  manipulate  64-bit files on a platform that cannot support them
5 Error starting client-server protocol
6 Daemon unable to append to log-file
10 Error in socket I/O
11 Error in file I/O
12 Error in rsync protocol data stream
13 Errors with program diagnostics
14 Error in IPC code
20 Received SIGUSR1 or SIGINT
21 Some error returned by waitpid()
22 Error allocating core memory buffers
23 Partial transfer due to error
24 Partial transfer due to vanished source files
25 The --max-delete limit stopped deletions
30 Timeout in data send/receive
35 Timeout waiting for daemon connection
EOF


}



function curl_err () {
IFS="
"
if [ $1 -le 7 ] && [ $1 -ge 0 ]; then
cat << EOF | egrep ^$1
1 Unsupported protocol. This build of curl has no support for this protocol.
2 Failed to initialize.
3 URL malformed. The syntax was not correct.
4 A  feature  or  option  that  was  needed to perform the desired request was not enabled.
5 Couldn't resolve proxy.  The  given  proxy  host  could  not  be resolved.
6 Couldn't resolve host. The given remote host was not resolved.
7 Failed to connect to host.
EOF
else [ $1 -ne 0 ] && echo "$1 Unknown nor documented error!"
fi

}

function send_email(){
MESSAGE=$1
SUBJECT=$2
ERRORMSG=$3

email -r smtp.virtualhostcr.com -p 587 -s "$SUBJECT" -a $ERRORMSG -tls -u aguila -i "27lapi8" -b -f alerts@virtualhostcr.com -n "Notificaciones Virtualhostcr" aguila@virtualhostcr.com
mutt -nx  -e "set from=alerts@virtualhostcr.com" -e "set realname='Alertas VirtualHostCR'" -e "set charset=utf-8" -e "set content_type=text/html" -s 'Notificaciones Virtualhostcr' -- aguila@virtualhostcr.com   < /tmp/body.html

}
