I am messing around with an rsync script to sync some stuff over to my phone. I am trying to write an if statement that decides which message I get in an email upon the commands completion. For some reason, I get both emails no matter how the command exits.

```
success_message=echo "Podcasts are synced." | mail -s "Your podcasts have been synced to   your phone." $email_address
fail_message=echo "Your phone did not sync." | mail -s "For some reason, your podcasts did not sync today." $email_address

rsync --log-file=/home/jake/logs/rsync.log -avzu $local_directory $remote_directory
if [ $? -ne "0" ];
then
  $fail_message
else
  $success_message
fi

```