首页 > ios9.3上面使用苹果自带的发邮件类库,发送邮件到企业邮箱结果失败了

ios9.3上面使用苹果自带的发邮件类库,发送邮件到企业邮箱结果失败了

我用这段代码在ios8上面能正常发送邮件到企业邮箱,但是到了ios9上面邮件就发送失败了,是不是用在ios9上面发邮件还需要什么设置丫

    MFMailComposeViewController *mailPickerVc = [[MFMailComposeViewController alloc] init];
    mailPickerVc.mailComposeDelegate = self;
    [mailPickerVc setSubject:PROJECT_NAME];//邮件主题
    [mailPickerVc setToRecipients:@[EMAIL_AUTHOR_ADRESS]];//设置收件人
    [mailPickerVc setMessageBody:@"管理驾驶舱 : \n" isHTML:NO];
    UIImage *image = _cutScreenBgView.saveImage;
    NSData *imageData = UIImagePNGRepresentation(image);
    [mailPickerVc addAttachmentData:imageData mimeType:@"" fileName:@"管理驾驶舱.png"];
    [self presentViewController:mailPickerVc animated:YES completion:nil];
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    NSString *message;
    switch (result) {
        case MFMailComposeResultCancelled:message = @"取消编辑邮件";
            break;
        case MFMailComposeResultSaved: message = @"保存邮件";
            break;
        case MFMailComposeResultSent:message = @"发送邮件";
            break;
        case MFMailComposeResultFailed:message = @"保存邮件/发送邮件失败";
            break;
        default:
            break;
    }
    [UIAlertView showMsgWithTitle:@"发邮件" msg:message confirm:@"确定" cancel:nil blocks:^(NSInteger index) {
        if (index == 0) {//确定
            [TAPublicUtilitiy judjeIsTimeOutSessionAndUpdateActivieSessionTimeCompletion:^(BOOL isShow) {
                if (isShow) {
                    //展示登录页面
                    [self presentViewController:[TAPublicUtilitiy showLoginVc] animated:NO completion:nil];
                } else {
                    [_cutScreenBgView removeFromSuperview];
                    _cutScreenBgView = nil;
                    [self dismissViewControllerAnimated:YES completion:nil];
                }
            }];
        }
    }];
}

能否把- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(nullable NSError *)
的error打印一下?


需要设置邮箱账户。

【热门文章】
【热门文章】