Taylor Swift has been granted a restraining order against a man who's allegedly been stalking her for years.

TMZ reports that Swift filed legal documents claiming that Timothy Sweet has been stalking her since 2011. According to court documents TMZ obtained, Sweet has sent a large number of letters, emails and social media posts professing his love for Swift, to whom he apparently believes he is married.

In her filing, Swift says she is worried about her safety and that of her family, since the tone of some of the messages is threatening. Among the messages, Sweet allegedly wrote, "If anyone in Taylor Swift's family gets killed, it is not my fault."

He also reportedly wrote, "My wife, Taylor Swift (Sweet) and I live in Beverly Hills. I am in love with her. In conclusion, we treat each other with dignity and respect. I will carry a gun to protect her the rest of my life."

One particularly unusual passage even seemed to target Secretary of State John Kerry: "Dearest Taylor, I'll kill any man who gets in the way of our marriage. Message to John Kerry, Secretary of State. Message from YOUR Presidential Candidate."

A judge has ordered Sweet to stay at least 100 yards away from Swift and three of her family members.

More From TheBoot