Praise be to Allah.
The ruling on touching non-mahram women is that it is haraam, during Ramadaan and at other times, whether that is touching with the hand only or actions that are more serious than that, because the Prophet (peace and blessings of Allaah be upon him) said: “If one of you were to be stabbed in the head with an iron needle, that would be better for him than his touching a woman who is not permissible for him.” Narrated by al-Tabaraani in al-Kabeer, 486; classed as saheeh by al-Albaani in Saheeh al-Jaami’, 5045.
Sins in general – including touching women – are more serious in Ramadaan. They detract from the reward of fasting, and may even spoil the fast altogether so that the fasting person gets nothing from his fast except hunger and thirst. Hence the fasting person is told most emphatically to avoid sin.
The believer should make the most of Ramadaan to set himself straight, to repent from sin and to turn to Allaah. The day when he fasts and the day when he does not fast cannot be the same.
Jaabir ibn ‘Abd-Allaah (may Allaah be pleased with him) said: When you fast, then let your hearing, sight and tongue fast and abstain from lies and haraam things, and refrain from harming your neighbour. Be tranquil and dignified on the day when you fast, and do not let the day when you fast and the day when you do not fast be the same.
Narrated by Ibn al-Mubaarak in al-Zuhd, 1308.
See also Question no. 37658
If a man shakes hands with a woman during the day in Ramadaan, and he ejaculates, his fast is invalidated, and there is no difference of opinion among the scholars on this point. He has to repent to Allaah from this sin, refrain from eating and drinking for the rest of the day, and make up that day’s fast later on.
See al-Mughni by Ibn Qudaamah, 4/361
With regard to emission of semen whilst fasting, if that happens without desire, e.g. because of sickness, then it does not affect the fast.
The Standing Committee was asked:
I suffer from seminal discharge during the days in Ramadaan without any wet dreams or engaging in the “secret habit” (masturbation). Does this have any effect on the fast?
If the matter is as described, the emission of semen without any feelings of pleasure during the day in Ramadaan does not affect your fast, and you do not have to make up that day.
Fataawa al-Lajnah al-Daa’imah, 10/278.
But if the emission of semen is accompanied by desire, one of two scenarios applies:
1 – That happens because the man does something that provokes his desires, such as kissing his wife, shaking hands with a woman with desire, etc. This invalidates the fast and he must make up that day later on.
2 – The semen is emitted without the man doing anything, such as simply thinking about desire, or because of a wet dream. This does not invalidate the fast and his fast is still valid.
Shaykh Ibn Baaz (may Allaah have mercy on him) said:
With regard to the emission of semen as the result of desire, this invalidates the fast whether that happened because of touching or kissing or repeatedly looking, or any other reason that provokes desire, such as masturbation etc. With regard to wet dreams and thinking, these do not invalidate the fast even is semen is emitted as a result.
Fataawa Islamiyyah, 2/135
And Allaah knows best.