ios4.3.4: MFMailComposer doesn't send an email, but return MFMailComposeResultSent status

末鹿安然 提交于 2019-12-12 03:14:42

问题


I am using MFMailComposer. I send email to gmail, MFMailComposer returns MFMailComposeResultSent status. But I don't received any email. I tested on iphone4 with 4.3.4. What I do wrong?

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];
 }
}

EDIT: I found this in console :

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

EDIT2: On iPhone4 with 4.3.4 doesn't work, but on ipod with 4.3 works OK.


回答1:


You do nothing wrong. Check this line from Apple's website:

MFMailComposeResultSent – The email message was queued in the user’s outbox. It is ready to send the next time the user connects to email.




回答2:


Dont release the mail picker at the specified spot [mailPicker release]; .. try using the Autorelease method for the

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

the rest is good.



来源:https://stackoverflow.com/questions/8257171/ios4-3-4-mfmailcomposer-doesnt-send-an-email-but-return-mfmailcomposeresultse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!