The solution is a Green's function G{z,z2) = G{z-z2) = G{Z}, with Z = z-z2, which obeys the differential equation
G''{Z)-k^2 G(Z) = -delta(Z). The minus sign is conventional.
In[45]:= DSolve[G''[Z] - k^2*G[Z] == -DiracDelta[Z], G[Z], Z]
Out[45]= {{G[Z] ->
E^(k Z) C[1] + E^(-k Z) C[2] - (
E^(-k Z) (-1 + E^(2 k Z)) HeavisideTheta[Z])/(2 k)}}
Now we need to determine C[1] and C[2] by the boundary conditions G[Infinity]=G[-Infinity]=0. From the first condition, as Z->+Infinity,
E^(-k Z) becomes negligible, so the asymptotic solution approaches G(Z) = E^(k Z) C[1] - E^(k Z)/{2k).This implies that C[1] = 1/(2k).
Setting C[2]= 0, we find G(Z) = E^(-k Z)/(2k) for Z>0. The second boundary condition leads to E^(k Z)/(2k) for Z<0. Thus the final result is G(Z) = E^(k|Z|)/(2k).