I currently use this message to send e-mails in a script but I would also like to save the output of this code to a file as well while preserving the variables. What's the easiest way to accomplish this?
#Sending mail notification
when=`/bin/date`
/usr/sbin/sendmail -t >2 <<-EOM
Subject:User access disabled.
From:testuser@test.com
To:$EMAIL
User $USERNAME has been disabled.
Regards,
$variable Support.
EOM