Consider a scalar field coupled to a source $$(\Box - m^2)\phi(x) = -J(x)\tag{1}.$$ Then, the response of the source is determined by the Green's function $G(x-y)$, which satisfies $$(\Box - m^2)G(x-y)=-\delta(x-y) \tag{2}.$$ In Euclidean signature the Green's function which is the solution of the previous equation, can be written as the Fourier transform $$G(x-y)= \int \frac{d^dk}{(2\pi)^d} \frac {e^{ik\cdot(x-y)}}{k^2+m^2} \tag{3}.$$ I cannot understand how given (3) the solution of (1) can be expressed as the integral $$\phi(x)=\int d^d y G(x-y)J(y)\tag{4}.$$
My guess is that one has to take (1) and act somehow (4) but right now I cannot see how to arrive to (4). I would appreciate some help.
P.S. My main problem is the fact that in the following semi-proof \begin{align} (\Box-m^2)\phi &= (\Box - m^2)\int dy \, J(y) \phi_i(x-y) \\ &= \int dy \, J(y) {\color{red}{(\Box - m^2)}}\phi_i(x-y) \\ &= \int dy \, J(y) {\color{red}{\delta(x-y)}} \\ &= J(x) \end{align} Not only I do not get the minus sign of (1) but also I do not understand why we use the homogeneous Klein-Gordon equation to get the red delta function in a problem where we begun with the inhomogeneous one!
\color{}{}
command. $\endgroup$