错误我试图通过我的应用程序发送电子邮件,但我得到了那个叫“请设置邮件帐户,以发送电子邮件”在斯威夫特
“请设置邮件帐户,才能发送错误电子邮件”。
我的码块是下面。
import MessageUI
@IBAction func emailTapped(_ sender: Any) {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients(["[email protected]"])
mailComposerVC.setSubject("Sending you an in-app e-mail...")
mailComposerVC.setMessageBody("Sending e-mail in-app is not so bad!", isHTML: false)
if MFMailComposeViewController.canSendMail() {
self.present(mailComposerVC, animated: true, completion: {() -> Void in })
}
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Swift.Error?){
controller.dismiss(animated: true) {() -> Void in }
}
你有没有设置要测试的设备上的电子邮件帐户? – rmaddy
为什么你做所有的工作来设置邮件控制器,你做检查,看看是否你实际上可以发送电子邮件前? – rmaddy