The family of US journalist James Foley, whose gruesome beheading was shown in a video released by Islamic State terrorists, on Monday published a letter he managed to smuggle past his captors by asking a fellow hostage to memorize the entire text.

Foley’s family posted the letter on the website they set up to campaign for his release and on the accompanying Facebook page, along with the remarkable tale of how their son arranged delivery of the note.

During his two years in captivity, Foley’s IS guards would not allow him to write any letters to his family, seizing any material they found.

However, in June the resourceful Foley asked another hostage, who was due to be released, to commit to memory a letter for his family. After he was freed, the unnamed hostage kept his word, contacting Diane Foley, James’s mother, and reciting the text to her.

“Dear family and friends,” the letter from Foley begins. before going on to recall happy memories: “so many great family times that take me away from this prison.”

Foley described some of the conditions of his captivity along with 18 others in a single cell. The hostages passed the time by talking about “movies, trivia, sports” and played games such as chess and checkers using bric-a-brac that they found in their cell.

The strain of captivity took its toll, Foley admitted, with “weak and strong days.” At the time he reported they were being better fed and he had regained some of the weight he had lost in the past.

Foley spoke of his three brothers and sister, the games they had played as children, their lives now that they were adults. In an ominous premonition, he gave instructions on what should be done with any money left in his bank account.

He also sent a special message to his grandmother, advising her to keep taking her medicine and promising to take her out to dinner when he got home.

“Stay strong because I am going to need your help to reclaim my life,” he said, bringing the letter to an end.

Last week IS posted a video on the YouTube Internet site showing Foley’s execution, which it said was in retaliation for US air raids on its positions and fighters in Iraq.