What is the biblical basis to say it is the duty of every minister to know his congregation? There seems to be two possible ways that a preacher can feed their flock.  One, they can be inspired by God to preach sermons that give people exactly what they need in due season without ever realizing the sermon just fits the needs of the church. Two, they really get to know each person in the congregation and develop a clear understanding what their needs are to preach sermons that match what they can see.

My question is, what is the biblical basis that a preacher must engage the members getting to know them and their thoughts, rather than just bury himself in theological study and prayer barely knowing his congregation?
My opinion is to look at the life of Paul.

Paul's ministry was the largest and covered a wide geographical area. He met many different people along the way, many towns and cities. When I read the epistles of Paul, I'm surprised to see how well he remembered the believers from different corners of the region and his intimate relationship with them. In most of his letters, at the end, Paul included greetings to the church members by name and their activities that he remembered. I think this indicates how well Paul knew his church members. Here is an example.


  Romans 16  (NIV)
  
  [....]
  
  6 Greet Mary, who worked very hard for you.
  
  7 Greet Andronicus and Junia, my fellow Jews who have been in prison
  with me. They are outstanding among the apostles, and they were in
  Christ before I was.
  
  8 Greet Ampliatus, my dear friend in the Lord.
  
  9 Greet Urbanus, our co-worker in Christ, and my dear friend Stachys.
  
  10 Greet Apelles, whose fidelity to Christ has stood the test.
  Greet those who belong to the household of Aristobulus.
  
  11 Greet Herodion, my fellow Jew.
  Greet those in the household of Narcissus who are in the Lord.
  
  12 Greet Tryphena and Tryphosa, those women who work hard in the Lord.
  Greet my dear friend Persis, another woman who has worked very hard in
  the Lord.
  
  13 Greet Rufus, chosen in the Lord, and his mother, who has been a
  mother to me, too.
  
  14 Greet Asyncritus, Phlegon, Hermes, Patrobas, Hermas and the other
  brothers and sisters with them.
  
  15 Greet Philologus, Julia, Nereus and his sister, and Olympas and all
  the Lord’s people who are with them.
  
  [.....]


Conclusion: Inspiration from God is the most important factor for delivering effective sermons and additionally, it is also important for the minister to know the state of his sheep and have an intimate relationship with them, just as Paul did with his church members.