我是这个话题的新手,请帮助我...
我正在使用帮助 Skpsmtpmessage 类将用户信息发送到 SMTP 服务器。但我收到“操作无法完成”。在-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error)
请帮帮我。
- (void) sendMessage {
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
NSString *myString;
testMsg.relayHost = @"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = @"my gmail id";
testMsg.pass = @"my gmail password";
testMsg.subject = [NSString stringWithFormat:@"CLIENT iPhone App - %@", self.navigationItem.title];
testMsg.bccEmail = emailField.text;
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
testMsg.fromEmail = emailField.text;
NSString *ff = [[UIDevice currentDevice] uniqueIdentifier];
NSString *gg = [[UIDevice currentDevice] model];
NSString *hh = [[UIDevice currentDevice] localizedModel];
NSString *ii = [[UIDevice currentDevice] name];
NSString *jj = [[UIDevice currentDevice] systemName];
NSString *kk = [[UIDevice currentDevice] systemVersion];
NSString *path;
if ([self.navigationItem.title isEqualToString:@"Request Authorization"])
{
path = [[NSBundle mainBundle] pathForResource:@"ThankYou" ofType:@"txt"];
testMsg.toEmail = @"myname@gmail.com";
}
else
{
path = [[NSBundle mainBundle] pathForResource:@"ThankYou2" ofType:@"txt"];
testMsg.toEmail = @"myanme@gmail.com";
}
NSString *fileText = [NSString stringWithContentsOfFile:path];
myString = [NSString stringWithFormat:@"LEADERS %@-\n\n%@\n\nName: %@\nCompany: %@\nAddress: %@\nCity: %@\nState: %@\nZip: %@\nPhone: %@\nFax: %@\nEmail: %@\nComments: %@\nRequire New Merchant Account: %@\nReferral Code: %@\nIdentifier: %@\nModel: %@\nLocalized Model: %@\nName: %@\nSystem Name: %@\nSystem Version: %@",self.navigationItem.title,fileText, firstNameField.text,companyField.text,addressField.text,cityField.text,stateField.text,zipCodeField.text,phoneField.text,faxField.text,emailField.text,countryField.text,customerIdField.text,lastNameField.text,ff,gg,hh,ii,jj,kk];
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
myString,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil,nil];
testMsg.delegate= self;
[testMsg send];
[self.navigationController popViewControllerAnimated:TRUE];
}