MFMailComposeResultFailed ってどのタイミングで実行されるの?

メールがエラーになった時に MFMailComposeResultFailed が呼ばれると思ったけど、sendすると MFMailComposeResultSent がすぐ呼ばれるみたい。airplane modeでやっても MFMailComposeResultSent がよばれる。

[objc]

//ぐぐるとこんなふうにコード書いてるのをよく見かける

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error

{

DLog();

UIAlertView *alert;

switch (result){

case MFMailComposeResultCancelled:

//キャンセルした場合

break;

case MFMailComposeResultSaved:

//保存した場合

break;

case MFMailComposeResultSent:

//送信した場合

break;

case MFMailComposeResultFailed:

alert = [[UIAlertView alloc] initWithTitle:@"メール送信"

message:@"メールの送信に失敗しました。ネットワークの設定などを確認して下さい"

delegate:self cancelButtonTitle:@"確認" otherButtonTitles:nil];

[alert show];

break;

}

[self close];

}

[/objc]

色々調べたら MFMailComposeViewController 自体にはメール送信を保証するための方法がない?

Using this interface does not guarantee immediate delivery of the corresponding email message. The user may cancel the creation of the message, and if the user does choose to send the message, the message is only queued in the Mail application outbox. This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent.

MFMailComposeViewController Class Reference

もうちょっと挙動をよくしらべたら airplane mode のときに send したメールは Outbox に貯まっていき、 airplane mode が解除されたら自動で送信されている。じゃあ MFMailComposeResultFailed が実行されるのは本当に通信中にエラーになったときだけ実行されるのかな?

おわり。