MailCompositionService quit unexpectedly. is this an apple problem or is there something wrong with what I'm doing?

im curious this is an issue on my end or apples end?


this is my code:



@IBAction func SendEmail(sender: AnyObject) {

var SubjectText = "This is Jeremy: "

SubjectText += Subject.text!

let MessageBody = Body

let mc: MFMailComposeViewController = MFMailComposeViewController()

let toRecipients = ["polarmp3@gmail.com"]

mc.mailComposeDelegate = self

mc.setSubject(SubjectText)

mc.setMessageBody(MessageBody.text, isHTML: false)

mc.setToRecipients(toRecipients)

self.presentViewController(mc, animated: true, completion: nil)

}

Where does it quit exactly ?

What is Body ? Why spaces in the toRecipients ?

Advice: var and func names whould not start with capital (send vs Send)


Here is an implementation that works for me ; you will notice I test MFMailComposeViewController.canSendMail ;

    func sendMail() {
     
        let mc = MFMailComposeViewController()
        if !MFMailComposeViewController.canSendMail() {
            print("Cannot send mail")
            return
        }
      
        mc.mailComposeDelegate = self
        mc.setCcRecipients([])
       body = "any body"
       mc.setToRecipients([destinee!])
        mc.setSubject(objet!)
        mc.setMessageBody(body!, isHTML: false)
        presentViewController(mc, animated: true) { (completion) in
                // I update a button bar here
            }
    }

I'm guessing you are trying it on a simulator. Various versions of the simulators have caused this error when you try to send an email, and on other versions it "pretends" to send the email. For example, it "works" in the iOS 8.4 simulator (no error, but no email is actually sent), but this error occurs on the iOS 9.3 simulator. The current trend seems to be that (simulating) sending email on a simulator is not possible. I say this because the iOS 10 beta simulator returns false from .canSendMail(), and there is no way to set up an account in the simulator's settings.


EDIT: removed some duplicate text.

MailCompositionService quit unexpectedly. is this an apple problem or is there something wrong with what I'm doing?
 
 
Q