Welcome to the community @zakjka. This sounds like a fun project!
To be able to give you a good answer to this it would help a lot if you posted your code or some more details about why it needs to be restarted. Please do so if the rest of this question misses the mark.
It sounds like you have a script that waits for your motion sensor to trigger, then sends an email and exits/finishes. If this is the case the easiest solution is to put it all in a while loop with "true" as a conditional. By doing this the loop will start from the top each after each time your existing code executes. It would look something like this:
while true:
# your code goes here
You might also want to handle the execution of this script as a service with systemd. By doing this you will be able to have your code run as a service/without an interactive user session each time your pi boots. You can find a guide for how to do this here: https://www.makeuseof.com/what-is-systemd-launch-programs-raspberry-pi/
I can also recommend this book for learning more about python: https://automatetheboringstuff.com/
Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev