在我的iPhone應用程序中,我使用SMTP發送郵件。但有時郵件發送後,應用程序突然出現以下錯誤信息使用SMTP發送郵件後,應用程序崩潰
<Warning>: Application 'UIKitApplication:com.myid.smtpsample[0x2630]' exited abnormally with signal 11: Segmentation fault: 11
��May 6 17:07:21 Device-3 ReportCrash[13041] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
崩潰這是我的代碼:
-(void) sendEmail
{
NSData *imagedata=UIImageJPEGRepresentation(image, 0.2f);
SKPSMTPMessage *Message = [[SKPSMTPMessage alloc] init];
Message.fromEmail = @"my email";
Message.toEmail = receiverEmailString;
Message.relayHost = @"smtp.gmail.com";
Message.requiresAuth = YES;
Message.login = @"my email";
Message.pass = @"my password";
Message.subject = @"Details";
Message.wantsSecure = YES;
Message.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,@"Message Body",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
NSDictionary *vcfPart= [NSDictionary dictionaryWithObjectsAndKeys:@"image/jpeg;\r\n\tx-unix-mode=0644;\r\n\tname=\"MyPhoto.jpg\"",kSKPSMTPPartContentTypeKey,
@"attachment;\r\n\tfilename=\"MyPhoto.jpg\"",kSKPSMTPPartContentDispositionKey,[imagedata encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
Message.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil];
[Message send];
}
- (void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{
NSLog(@"delegate - error(%d): %@", [error code], [error localizedDescription]);
}
- (void)messageSent:(SKPSMTPMessage *)message{
NSLog(@"delegate - message sent");
}
請告訴我,我做錯了
由於您沒有給出示例代碼,因此我必須爲代碼投票選出相同的解決方案。 – Thiru 2015-06-04 13:00:53
@Thiru,我明白了。它更容易複製和粘貼解決方案,而不必考慮代碼的功能,或者爲什麼。愚蠢的我 - 我只是一個老派的開發者。 – 2015-06-04 13:55:29