Adding a hook in the final sendmail function.