Sweetie this is a bit more serious I think.
Firstly, he was nasty to you before this. The text messages aren't the reason for that.
Secondly, no wonder you had a smidgen of a good time elsewhere. I would have done too.
But back to the immediate problem. He's violent and threatening. There are two adults at risk.
I would say, ring a DV charity and get a safety plan created, one that you think will work. Plan to leave, how to leave, who to tell, and what to say to your husband afterwards.
He needs to be told that, because of his threats and his behaviour, you've got professionals involved. Be vague about whom. Then, that you have left him and you're not telling him where you are. If he seeks you out or comes to work, you or your parents or the man at work or the boss at work will ring the police and he will be removed. Then, that you never want to hear from him directly again, all via solicitors, and that if he harasses you you will report him.
Next you need support. Drag up the worst stories and tell your best friends and parents and ask for their help. They will not be disappointed, they will be very pleased you've escaped.
The point of leaving is the highest risk part. It means not walking alone, having people know when you should arrive back, not opening the door to him, calling for help if needs be, having phone in hand. The main things are to tell him straight, to ring off, not to respond ever and to report threats. Reporting threats means he'll be spoken to and he may need that xxx