Multi-source domain adaptation (MSDA) aims to transfer knowledge from multi-source domains to an unlabeled target domain, making it highly suitable for cross-session and cross-subject emotion recognition based on electroencephalography (EEG). Nevertheless, current MSDA models primarily focus on the relationship between the global feature distribution of the source and the target domain while neglecting the relationship between local feature pairs, resulting in poor robustness. In this study, we propose an EEG-based Multi-Source Domain Knowledge Transfer Framework (MS-KTF) for cross-session and cross-subject emotion recognition. The MS-KTF uses a triplet loss combined with a maximum mean discrepancy (MMD) to achieve unbiased alignment at both the domain and data-pair levels of each pair data in the source and target domains. Moreover, the introduction of knowledge distillation enables MS-KTF to achieve better robustness without requiring additional training time. We evaluated the MS-KTF's performance on the DEAP, SEED and SEED-IV datasets for two-, three- and four-class emotion recognition, respectively. The experimental results demonstrated that MS-KTF achieves competitive performance in both cross-session and cross-subject scenarios.