Taylor Swift has had a stalker for 2 years and his threats have been horrifying ... he has threatened to kill and rape her, and he boasts no one can stop him from doing it.

Taylor just got a restraining order against 26-year-old Eric Swarbrick, who has been sending Taylor letters since Sept. 2016. Among the letters sent by the Tennessee resident ...

-- "I want to rape Taylor Swift. This is why I hate Taylor herself ... This is how I know I am Taylor's soulmate."

-- "I have learned to absolutely repress the metaphorical monster in me, but, very soon, I will become completely responsible for myself ... What logical conclusion is there other than death."

-- "I will not hesitate to kill her ... and there's nothing you, your lawyers, or the law will be about to do about it. Remember who I am."

According to legal docs filed by Taylor's lawyers, the letters have become increasingly alarming over the last few months, and it's caused stress, fear and anxiety. The lawyers say there is a real worry Swarbrick will make good on his threats.