The only option is to manually telnet to the smtp port on the authoritative mailserver for the target domain. As otherwise unless a mail-host is configured as an email relay, you will be unable to send an email to a user outside of the mailservers domain (without authentication).
localMESSAGE="${1:-"The Postfix service has failed to come up on tartarus (192.168.3.2) after a service restart. Please ssh into server to troubleshoot the issues."}"
## Getting a mailserver IP for manual message
MAILSERVER=`dig $DOMAIN mx | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'| head -n 1`
## Setting up coprocess to send commands to telnet session
coproc TELNET { telnet $MAILSERVER 25;}
## Commands to send email manually
local -a commands=(
"ehlo camtel.net\n"
"mail from: <$MAIL_FROM>\n"
"rcpt to: <$NOTIFY_EMAIL>\n"
"data\n"
"Subject: Postfix Service Failure\nFrom: $MAIL_FROM\nTo: $NOTIFY_EMAIL\n"
"$MESSAGE\n\n.\n"
"quit\n"
)
## Iterate through commands and send them to coprocesses
### We need to wait before each command as the remote mailserver will not catch everything otherwise.
for i in ${!commands[@]};do
COMMAND="${commands[$i]}"
echo -e "$COMMAND" >&${TELNET[1]}
sleep $WAIT
done
}
# END: Helper Functions
# BEGIN: Test Check
if[[$TEST -eq 1]];then
MESSAGE_1="
This is a test message to verify that postfix can send an email
"
send_email "$MESSAGE_1"
MESSAGE_2="This is a test email to make sure the postfix crash workaround email works"