In a quantum network, a key challenge is to minimize the direct reflection of flying qubits as they couple to stationary, resonator-based memory qubits, as the reflected amplitude represents state transfer infidelity that cannot be directly recovered. Optimizing the transfer fidelity can be accomplished by dynamically varying the resonators coupling rate to the flying qubit field. Here, we analytically derive the optimal coupling rate profile in the presence of intrinsic loss of the quantum memory using an open quantum systems method that can account for intrinsic resonator losses. We show that, since the resonator field must be initially empty, an initial amplitude in the resonator must be generated in order to cancel reflections via destructive interference; moreover, we show that this initial amplitude can be made sufficiently small as to allow the net infidelity throughout the complete transfer process to be close to unity. We then derive the time-varying resonator coupling that maximizes the state transfer fidelity as a function of the initial population and intrinsic loss rate, providing a complete protocol for optimal quantum state transfer between the flying qubit and resonator qubit. We present analytical expressions and numerical examples of the fidelities for the complete protocol using exponential and Gaussian profiles. We show that a state transfer fidelity of around 99.9% can be reached for practical intrinsic losses of resonators used as quantum memories.