We investigate how synchrony can be generated or induced in networks of electrically coupled integrate-and-fire neurons subject to noisy and heterogeneous inputs. Using analytical tools, we find that in a network under constant external inputs, synchrony can appear via a Hopf bifurcation from the asynchronous state to an oscillatory state. In a homogeneous net work, in the oscillatory state all neurons fire in synchrony, while in a heterogeneous network synchrony is looser, many neurons skipping cycles of the oscillation. If the transmission of action potentials via the electrical synapses is effectively excitatory, the Hopf bifurcation is supercritical, while effectively inhibitory transmission due to pronounced hyperpolarization leads to a subcritical bifurcation. In the latter case, the network exhibits bistability between an asynchronous state and an oscillatory state where all the neurons fire in synchrony. Finally we show that for time-varying external inputs, electrical coupling enhances the synchronization in an asynchronous network via a resonance at the firing-rate frequency.