The pineal gland has a romantic history, from pharaonic Egypt, where it was equated with the eye of Horus, through various religious traditions, where it was considered the seat of the soul, the third eye, etc. Recent incarnations of these notions have suggested that N,N-dimethyltryptamine is secreted by the pineal gland at birth, during dreaming, and at near death to produce out of body experiences. Scientific evidence, however, is not consistent with these ideas. The adult pineal gland weighs less than 0.2 g, and its principal function is to produce about 30 µg per day of melatonin, a hormone that regulates circadian rhythm through very high affinity interactions with melatonin receptors. It is clear that very minute concentrations of N,N-dimethyltryptamine have been detected in the brain, but they are not sufficient to produce psychoactive effects. Alternative explanations are presented to explain how stress and near death can produce altered states of consciousness without invoking the intermediacy of N,N-dimethyltryptamine.
Nichols, D. E. (2017). N, N-dimethyltryptamine and the pineal gland: Separating fact from myth. Journal of Psychopharmacology
Link to full text