Reference: Fataawa li Ahlil-Mayyit – Question 20, Page 23
Liqaa. al-Baab al-Maftooh – Volume 70, Page 231
Question: Are greetings extended to the grave dwellers whilst visiting the graveyard, or in the street whilst walking past the graveyard?
Response: Greetings are extended to the grave dwellers whilst visiting the graveyard. As for passing by the graveyard which is walled in, then greetings are not extended [to the grave dwellers]. However, if it is not walled in, then some of the people of knowledge have said: If one passes by a graveyard, then greetings should be extended [to the grave dwellers] so as to attain the reward [for doing so], since [in extending greetings] one is [actually] supplicating for his brothers [and sisters], and as such is doing good for them, and in this is reward and good, in shaa.-Allaah.