ios4.3.4:MFMailComposer不发送电子邮件,但返回MFMailComposeResultSent状态

问题描述:

我正在使用MFMailComposer。我发送电子邮件给Gmail,MFMailComposer返回MFMailComposeResultSent状态。但我没有收到任何电子邮件。我用4.3.4在iphone4上测试过。我做错了什么?ios4.3.4:MFMailComposer不发送电子邮件,但返回MFMailComposeResultSent状态

MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init]; 
    mailPicker.mailComposeDelegate = self; 

    // Set the subject of email 
    [mailPicker setSubject:@"Subject"]; 
    NSString *emailBody = @"Hello from ios"; 

    // This is not an HTML formatted email 
    [mailPicker setMessageBody:emailBody isHTML:NO]; 


    [self presentModalViewController:mailPicker animated:YES]; 

    [mailPicker release]; 


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    if (result == MFMailComposeResultFailed) 
{ 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[error description] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alertView show]; 
    [alertView release]; 
} 
if (result == MFMailComposeResultSent) 
{ 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Message has been sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alertView show]; 
    [alertView release]; 
} 
else 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
} 
} 

编辑:我发现这个控制台:

DA|Could not open the lock file at /tmp/DAAccountsLoading.lock. We'll load the accounts anyway, but bad things may happen 

EDIT2:在iPhone4采用4.3.4不工作,而是在iPod 4.3工程确定。

+0

也许它被过滤掉为垃圾邮件? – Yahia

+0

我看着Gmail垃圾邮件,但我没有发现任何iPhone的邮件。 – Voloda2

+0

您是否尝试重新启动设备以清除/ tmp目录内容?也许这可以消除造成你麻烦的锁 – viggio24

不要松开邮件选择器在指定点[mailPicker release]; ..尝试使用自动释放方法为

MFMailComposeViewController *mailPicker = [[[MFMailComposeViewController alloc] init]autorelease]; 

剩下的就是好的。

+0

没关系。 'mailPicker'会在保留时显示为模态 – beryllium

+0

@beryllium我有同样的问题,所以我使用这种方法解决它,所以你可以请建议更好的东西...我也愿意更多地了解它在我的应用程序中实现。 – medampudi

你没有做错任何事。从苹果公司的网站上查询这一行:

MFMailComposeResultSent - 该电子邮件用户的发件箱排队。它准备在用户下次连接到电子邮件时发送。