It is appropriate to offer words of condolence to people an individual does not know well if the person feels genuine sympathy. Most people appreciate gestures of sympathy. It is also acceptable to offer condolences to strangers for the loss of an acquaintance who is their loved one.
An individual may also offer words of condolence to an acquaintance at an open memorial service. People should phrase condolences in their own words, and they do not need to include specific personal information. A text message is usually not a polite way to offer condolences, but a brief note, short phone call or even an e-mail might be acceptable for an acquaintance.