CFTR is the gene which encodes the "Cystic fibrosis transmembrane conductance regulator", which is a membrane protein. Its function is to transport chloride and other negatively charged ion like thiocyanate ions from the inside of the cell to the outside (into the extra cellular space). This happens along a gradient, meaning the ions flow from the place of high concentration (inside the cell) to the place of low concentration (outside the cell). Since this would mean that a negative charge would build up on the outside of the cell, positively charged sodium ions follow the chloride ions by passive diffusion. This ions are secreted into the mucus in the extra cellular space.
This leads to a higher concentrations of electrolytes (salts) outside of the cell, which causes water to leave the cell (following the higher concentration of electrolytes), which makes the mucus thinner.
When the CFTR gene is mutated, this function is impaired and ions cannot be transported across the membrane. This causes a higher electrolyte concentration inside the cell and water stays there. This causes the mucus to get thicker (due to less influx of water), which then can block fine channels of the lung. Additionally bacteria can grow in the thicker mucus, which can cause severe problems as pneumonia. The process functions as shown in the figure below (from here), the sodium ions are not shown here:
If you want to read further about cystic fibrosis, I recommend this website.
Regarding the immune system there are different functions affected. First, the reduced (or prevented) secretion if thiocyanate ions lead to a reduction in the production of Hypothiocyanite ions which kill bacteria. Then different cells which are of importance to a proper immune reaction are impaired in their function, as shown in the figure below (from the first reference):
The function of CFTR is impaired in all cell types, not only in epithelial cells in the lung (although these are the most obvious consequences). In the cells of the immune system (T-cells for example) the intracellular ion concentration is disturbed including Ca2+ which plays an important role in the regulation of other genes. Other observations show that the activation of the immune system itself is also affected.
Further informations can be found in the articles I linked below. They require some knowledge of immunology, but when there are question, ask.
- Immune Responses in Cystic Fibrosis
- The innate immune system in cystic fibrosis lung disease