"…When a woman conceives and gives birth to a male..." (Levit. 12:2).

The Baal Shem Tov taught: (Keter Shem Tov)

One should pray as if he were awakening the dawn, and not the dawn awakening him.

This means that one should toil diligently and gradually in the preliminary prayers until reaching Baruch She’amar. This first section is parallel to the world of Asiya, which is the lowest [of the Four Realms], the home of the impure kelipot. Then, one should intensify one's concentration from Baruch She'amar until Yishtabach; this section is parallel to the [next higher] world of Yetzira, in which the kelipot are few. Then, from Yishtabach [including Sh’ma Yisrael] until the silent Shemonah Esreh prayer, one should concentrate yet further. Finally, in the Shemonah Esreh, which represents a state of embrace and union [with the Divine], one should be completely detached from all physical sensation. (Shulchan Aruch, Orach Chaim #98)

If one follows this path, then one has first created mayin nukvin ["feminine waters"],(Toldos: Tazria 1) and only afterwards are the mayin dikhrin ["male waters"] aroused, which gives "birth" to a "male."

...if a person is aroused spontaneously, his prayer might be rejected.

However, if a person is aroused spontaneously, his prayer might be rejected. The way to rectify when such spontaneous arousal comes over a person, is to arouse deep regret and fear, and to then pray from the depths of one's heart.

This is meaning of the verse,(Proverbs 18:22) "One who finds a woman" (the mayin nukvin) - first - "has found good," and then, "will obtain favor from G‑d."

[Keter Shem Tov, section 259 (from “Toldos Yaakov Yosef”). Translation and Commentary by Rabbi Yehoshua Starrett. (Square-bracketed additions by KOL staff.)]