Secret Window

Amy Rainey divorces her husband, author Mort Rainey, and begins a relationship with Ted. Depressed and suffering from writer's block, Mort puts off finalizing the divorce and retreats to his cabin at Tashmore Lake in upstate New York. Mort is confronted by John Shooter, who accuses him of plagiarizing his story "Sowing Season." Upon reading Shooter's manuscript, he discovers its resemblance to his own story "Secret Window," except for the ending.
The following day, Mort explains that his story was published years before Shooter's was written. Shooter challenges him to provide proof and warns against involving the police. That night, Mort finds his dog killed with a screwdriver and reports to Sheriff Dave Newsome.
Mort drives to his house in Riverdale to find a copy of the magazine where his story was published, but leaves when he sees Amy and Ted. He contacts private investigator Ken Karsch for help. Ken agrees to travel to Tashmore Lake to watch the cabin and talk to Tom Greenleaf, a resident who might have seen Shooter talking to Mort. Shooter visits Mort at the cabin and demands Mort change the ending of "Secret Window" to Shooter's version, where the protagonist kills his wife. Shooter attacks and chokes Mort.
Amy calls Mort, saying their house was burned down. Mort travels to Riverdale and the two are questioned by a police officer. Ken calls Mort and says Tom Greenleaf denied seeing Mort. Ken suspects Tom was threatened by Shooter. They agree to confront Shooter together and arrange a meeting with Tom at a local diner.
The next morning, Mort oversleeps. Arriving at the diner, he learns that Ken and Tom didn't show up. Seeing Ted at a gas station, Mort approaches him and Ted demands Mort sign the divorce papers. The two have a confrontation and Ted breaks his hand. Shooter calls Mort to a meeting place. When he arrives, Mort finds Ken and Tom dead inside Tom's truck and faints. When he wakes up, Shooter says they were murdered with Mort's screwdriver for interfering with his business. Mort has the magazine as proof and Shooter agrees to meet at Mort's cabin. He leaves and Mort covers up the crime by running the truck into a water-filled stone quarry.
Amy calls Mort. She goes to his cabin and he signs the divorce papers. At the post office, Mort picks up the magazine sent by his literary agent. He finds the package already opened and the pages containing the story cut out. Back at his cabin, Mort sees Shooter's hat. Mort wears the hat and begins speaking to himself, trying to make sense of the events. Mort realizes that Shooter is just a figment of his imagination; brought to life through Mort's dissociative identity disorder. When Mort fainted or slept, "Shooter" took over and killed the dog, Tom, Ken and burned down his house.
When Amy arrives at the cabin, she finds it disheveled, with the word "SHOOTER" carved repeatedly on the walls. Mort appears and Amy realizes the name represents Mort's desire to "SHOOT HER." Mort, speaking with Shooter's accent, chases Amy and stabs her in the ankle. Concerned about Amy's safety, Ted arrives and is ambushed by Mort. Amy watches helplessly as Mort beheads Ted. Mort recites the ending of "Sowing Season" as he kills Amy off-screen.
Mort recovers from writer's block and experiences a mood improvement, but is now the town pariah. Sheriff Newsome stops by the cabin to warn Mort that he is the prime suspect in Amy and Ted's disappearances. Mort dismisses the threat and the Sheriff leaves. In Mort's room, there is a secret window that overlooks a secret garden. It is implied that the bodies are buried in the garden, which is now a cornfield, and the police will never find them. Mort is seen eating a corn cob and steak for dinner and the screen cuts to black.

Question: Who sent the magazine to Mort?
Answer: His literary agent