Home>

I want to start the mailer with the simulator.

Although the mailer starts on the actual machine
It will not start in the simulator.

With a simulator,
Is it because there is no mailer app?

Or version

Corresponding source code
import UIKit
import Message UI

class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
// @IBOutlet var button: UIButton!
    override func viewDidLoad () {
        super.viewDidLoad ()
    }
    @IBAction func sendMail (_ sender: Any) {
        if MFMailComposeViewController.canSendMail () {
            let mail = MFMailComposeViewController ()
            mail.mailComposeDelegate = self
            mail.setToRecipients (["[email protected]"]) // Destination address
            mail.setSubject ("Send email from app") // Title
            mail.setMessageBody ("Enter the body here.", IsHTML: false) // Body
            present (mail, animated: true, completion: nil)
        } else {
            print ("cannot send")
        }
    }
    func mailComposeController (_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
        switch result {
        case .cancelled:
            print ("cancel")
        case .saved:
            print ("Save Draft")
        case .sent:
            print ("Successful transmission")
        default: default:
            print ("Send failed")
        }
        dismiss (animated: true, completion: nil)
    }
}
Supplementary information (FW/tool version, etc.)

・ Version
MacOS: Catalina 10.15.5
Xcode: 11.6
iOS: 13.6