>  Q&A  >  본문

ios发邮件 - 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];
                }
            }];
        }
    }];
}
怪我咯怪我咯2763일 전629

모든 응답(2)나는 대답할 것이다

  • 迷茫

    迷茫2017-04-17 17:53:32

    이메일 계정을 설정해야 합니다.

    회신하다
    0
  • 怪我咯

    怪我咯2017-04-17 17:53:32

    - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(nullable NSError *)
    의 오류를 인쇄할 수 있나요?

    회신하다
    0
  • 취소회신하다