The note dated 1916 was discovered behind a fireplace in Kirkwall, Orkney, and signed "Your Blue Jacket Boy".
Addressed to the serviceman's family in Wales, it was sealed and stamped but never posted.
Staff at Orkney Library wanted to identify the author and made a successful appeal on their blog.
The hunt reached Canada where a distant relative suggested the sailor may be David John Phillips from Llanelli.
He contacted Mary Hodge in Chester who recognised the writer as her grandfather.
She is planning a visit to Orkney to pick up the letter addressed to her great-grandparents 98 years ago.
Ms Hodge said: "I've got shared ancestry with my friend in Canada. He's interested in his family history so he keeps an eye on the Orkney Library and Archive's blog.
"He called me about a week ago and said, 'I think you'd better get in touch with the archive folk at the Orkney Library - because I've seen a post on their blog and I'm sure it's about your grandfather'.
"I knew instantly it was my grandfather - I recognised the name and address on the picture of the letter. It was a mixture of high emotion, shock and disbelief.
"I'm not really a big user of the web, but thank goodness for the internet - this letter may never have come home without it.
"It's overwhelming to have a little piece of my beloved grandfather, after all this time."
David John Phillips, known as Dai, was stationed in Orkney during the First World War.
It is understood he served on HMS Cyclops, a depot and repair ship based at Scapa Flow.
He married Orcadian Catherine Isabella Coghill Johnston in 1919 before returning to Llanelli where the couple had two children and opened a greengrocer's shop.
Catherine's family lived in Bridge Street, Kirkwall, where the letter was discovered in 1980. It was handed to Orkney Library last year.
It is thought the envelope may have been propped up on the mantelpiece ready for posting but slipped down the back unnoticed.
In the letter Mr Phillips asks to be remembered by his family and mentions sending a handkerchief with a picture of a sailor on it.
Assistant archivist Lucy Gibbon said of the blog: "We posted it last year and asked our followers to help us find out the author's real name, and if he had any descendants.
"We meantime also worked with the local paper in Llanelli to get the story out that way too.
"We wanted to show the process of researching an inquiry to the public, and of course wanted to see if we could get this letter to his family.
"It certainly captured the imagination of our blog followers."
Ms Hodge, 60, said: "I don't live in Llanelli any more so I'd totally missed the articles in the local paper.
"I'm just so grateful to the archive for their blog, to the lady who first handed in the letter, and to everyone who posted comments and tried to help track my family down."