I recommend using sendy to do all this. It costs 60 dollars and from then it’s just amazon ses costs. The advantage is that you get a visual editor as well as bounce and subscribe handling and other cool analytics tools.
I’m not connected to them in any way. But if you’re relying on a script like this, sendy is a far better option and just as cheap.