The problem with reading the mail

Hello. I have an application where I read an email and depending on what result I read it turns my light bulbs on or off. the email is from securitas directly, but that has nothing to do with it. the problem is that one or two days, it crashes and no longer reads the mail and I have to restart it. what can i do to stop my email from getting stuck? I mention that I have it at 3 seconds, I tried to put it at 30 seconds (I don't have to put it anymore, it doesn't do the function I want). the settings are the ones in the picture, only I hid the ID.