Neutrinoless double beta decay, if detected, would prove that neutrinos are Majorana fermions and provide the direct evidence for lepton number violation. If such decay would exist in nature, then $pi^-pi^-to ee$ and $pi^-topi^+ ee$ (or equivalently $pi^-e^+topi^+ e^-$) are the two simplest processes accessible via first-principle lattice QCD calculations. In this work, we calculate the long-distance contributions to the $pi^-topi^+ee$ transition amplitude using four ensembles at the physical pion mass with various volumes and lattice spacings. We adopt the infinite-volume reconstruction method to control the finite-volume effects arising from the (almost) massless neutrino. Providing the lattice QCD inputs for chiral perturbation theory, we obtain the low energy constant $g_ u^{pipi}(m_rho)=-10.89(28)_text{stat}(74)_text{sys}$, which is close to $g_ u^{pipi}(m_rho)=-11.96(31)_text{stat}$ determined from the crossed-channel $pi^-pi^-to ee$ decay.