objective-c - 使用MFMailComposeViewController发送邮件失败

标签 objective-c ios cocoa-touch

我最近向苹果提交了一个应用,可惜它被拒绝了。给出的原因是它具有无法发送给 friend 的电子邮件功能。 (不用说,但是在我的设备上效果很好)。我正在使用MFMailComposeViewController,填写主题和正文并添加附件。然后,用户必须执行其余的操作才能发送。当我要求详细说明时,审稿人说...

我们随您的应用程序发送的电子邮件列在Gmail中,而Yahoo测试帐户“发件箱”则出现错误,指出无法访问外发邮件服务器。

...应该算作我的应用程式有错误吗?我实际上并不发送邮件,我只是使用内置的SDK调用来准备消息。我知道“是您的设备”这一说法并不能真正促使我批准我的应用,但我确实认为这是他们的设备。

任何人都可以想到导致此类消息的电子邮件失败的任何原因,以及那些原因,我实际上可以做的任何事情?

现在我的代码...

...我在哪里发送消息

- (void)sendMail
{
    NSData *vCards = (NSData *)ABPersonCreateVCardRepresentationWithPeople((CFArrayRef)self.selections);

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

    [mc setSubject:@"Contact"];

    [mc setMessageBody:@"<p>My message...<p>" isHTML:YES];  
    NSString *label = ([self.selections count] == 1)? (NSString *)ABRecordCopyCompositeName([self.selections objectAtIndex:0]): @"Contacts";

    [mc addAttachmentData:vCards mimeType:@"text/x-vcard" fileName:label];

    [self presentModalViewController:mc animated:YES];  
    [mc release];  
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {  
    switch (result) {  
        case MFMailComposeResultCancelled:  
            NSLog(@"Mail send canceled.");  
            break;  
        case MFMailComposeResultSaved:  
            NSLog(@"Mail saved.");  
            break;  
        case MFMailComposeResultSent:  
            NSLog(@"Mail sent.");  
            break;  
        case MFMailComposeResultFailed:  
            NSLog(@"Mail send error: %@.", [error localizedDescription]);  
            break;  
        default:  
            break;  
    }  
    [self dismissModalViewControllerAnimated:YES];  
}

现在,我了解到如果消息失败,我实际上并没有做任何有用的事情,但是如果消息在撰写级别上失败了,该消息甚至应该到达用户的发件箱吗?

我将提交另一个版本以警告错误详细信息,但我怀疑会有任何错误。

最佳答案

我做过类似的事情,您可以尝试不发送电子名片吗?告诉我是否可行...

关于objective-c - 使用MFMailComposeViewController发送邮件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8436492/

相关文章:

ios - UICollectionViewCell 中的 UIButton 上的 UIPopoverControl?

ios - UISlider - 将 UILabel 添加到最小/最大 UIImageView?

ios - Objective-C:方法的返回值和Completion block ,它们是如何执行的?

iphone - 使用 NSDateFormatter 解析 Twitter 字符串

ios - 将 NSString 转换为 NSDate(然后再返回)

objective-c - 让用户选择要打开的文档类型

iphone - 如何向导航栏添加多个按钮?

iphone - 无法信任 iphone 上的自签名证书

ios - 从表中传递选定的行以准备 segue Objective C

iphone - 使用 NSMutableSet 时出错