In this work, we present a synaptic transmission representing neural coding with spike trains by using a magnetic tunnel junction (MTJ). Telegraphic switching generates an artificial neural signal with both the applied magnetic field and the spin-transfer torque that act as conflicting inputs for modulating the number of spikes in spike trains. The spiking probability is observed to be weighted with modulation between 27.6% and 99.8% by varying the amplitude of the voltage input or the external magnetic field. With a combination of the reverse coding scheme and the synaptic characteristic of MTJ, an artificial function for the synaptic transmission is achieved.