As long as the teacher who wrote the recommendation letter has crossed paths with you.
For example, I took his class.
Worked as a teaching assistant for him
Or help with research.
Help him collect data.
Or have already sorted out the documents.
Or met at an academic conference.
After several hours of conversation,
He was deeply impressed by your views on major or problem.
And so on ~ ~