thank you for your query.
mucous is produced by the mucus membrane of the large intestine.
the causes for its passage are-
1.IBS-Irritable Bowel Syndrome
since you are saying that you have constipation
since long time,your symptoms fall under IBS.yours is the constipation dependent type.
treatment includes diet modification,high soluble fibre diet,exercise,medication such as laxatives,TCA's etc.
wishing you good health