Craft a security system

Is it possible to code a security system that could be crafted that could detect walls being hit or something , and when it does , send out an email to you to give you a chance to log in and try to defend your base?

No

You have to understand that the coding for such request would need lots of debugging and lots of headache and is not worth it having coders who work about 4 hours a day on a 120k yearly pay do a such thing.