I have a script which runs on multiple servers. Some servers are using sSMTP and some are using postfix.
I want to find which version of sendmail my server is running in runtime, because -t
is not supported in sSMTP but is mandatory in Postfix
Now the challenge begins.
sendmail -V
on sSMTP variant outputs sSMTP 2.64 (Not sendmail at all)
but
the postfix variant doesn't have the -V
option for displaying the version.
I managed to accomplish it with the following snippet.
VER=$(sendmail -V 2>/dev/null)
if [[ "sSMTP" == $VER* ]]; then
echo $BODY | sendmail $EMAIL #sSMTP
else
echo $BODY | sendmail -t $EMAIL #postfix
fi
Is there a more efficient method to achieve this?
I want to find what variant of sendmail is in my server. Not just postfix or sSMTP.