I'm having trouble sending an email in MFMailComposeViewController from inside my app. I get a log message that the email was sent, but it never sends to my account. I have to go to the native Mail app and send it from the outbox. There is no error telling me way it failed even inside the native app. Am I missing a privacy setting or something? This originally worked fine. I'm having the issue after iOS 10 update.
-(void)sendEmail:(NSString*)email order:(NSMutableArray *)orderA{
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
if ([MFMailComposeViewController canSendMail])
{
mail.mailComposeDelegate = self;
[mail setSubject:[NSString stringWithFormat:@"Order #%@ order", storeNum]];
[mail setMessageBody:[orderA description] isHTML:NO];
[mail setToRecipients:@[email]];
[self presentViewController:mail animated:YES completion:nil];
}
else
{
NSLog(@"This device cannot send email");
}
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result) {
case MFMailComposeResultSent:
NSLog(@"You sent the email.");
break;
case MFMailComposeResultSaved:
NSLog(@"You saved a draft of this email");
break;
case MFMailComposeResultCancelled:
NSLog(@"You cancelled sending this email.");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail failed: An error occurred when trying to compose this email");
break;
default:
NSLog(@"An error occurred when trying to compose this email");
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}