1) добавьте MFMailComposeViewControllerDelegate
в ваш делегат класса
добавить в код следующий код
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients([email ?? ""])
composeVC.setPreferredSendingEmailAddress(someEmail ?? "")
// composeVC.setSubject("Message Subject")
composeVC.setMessageBody("Checking", isHTML: false)
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
Затем добавьте эту функцию, чтобы вернуться в приложение, когда просмотр электронной почты отклоняет
func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWith result: MFMailComposeResult, error: Error?) {
// Check the result or perform other tasks.
// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}