When will [MFMailComposeViewController canSendMail] return NO

Solution 1:

If at least one email account is enabled on the device, the following call should return YES:

[MFMailComposeViewController canSendMail]

Conversely, if all accounts are disabled/removed, it will return NO.

Solution 2:

For +canSendMail to return YES the default account must be set-up for sending emails.

(Internally, +[MFMailComposeViewController canSendMail] calls +[MailAccountProxy defaultMailAccountForDelivery], which finds the first mail account being -isDefaultDeliveryAccount.)

Solution 3:

In addition to an email account not being setup on a device, canSendMail also returns NO when an MDM profile is installed and configured to not allow third party apps to send mail. In this case you must use openURL: with a mailto: URL in order to launch Mail.app and optionally fill in the to, cc, bcc, subject, and body field.

mailto: RFC

  • https://www.rfc-editor.org/rfc/rfc2368

Solution 4:

This worked for me.

In Device Go setting->Mail,Contacts,Calendar->Accounts

Here you can see no account is added.Now add account now go back to your app and you can find its returning yes this time and you are able to send E-mail. Thanks

Solution 5:

[MFMailComposeViewController canSendMail] will return NO when you don't have any mail account on device. In this case you can open mail app by the following code:

- (void)openMailApp {
    NSString *recipients = @"mailto:?cc=&subject=";
    NSString *body = @"&body=";
    NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
    email = [email stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}