在我的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