我尝试在不使用 MFMailComposeViewController 的情况下发送电子邮件,经过一些研究,我认为 AFNetowrking 是最好的方法,但我无法弄清楚并使其工作,而且我对 Web 编程并不十分熟悉。
我正在使用 AFHTTPClient 类,这是我所做的:
-(IBAction)sendMail
{
NSURL *url = [NSURL URLWithString:@"http://flameapp.net"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
txtName, @"si_contact_name1",
txtSubject, @"si_contact_subject1",
txtEmail, @"si_contact_email1",
txtMessage, @"si_contact_message1"
,nil];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"/?page_id=26" parameters:params];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:
[NSURL URLWithString:@"http://flameapp.net/?page_id=26"]];
NSURLResponse *response = [[NSURLResponse alloc] init];
[client postPath:@"/?page_id=26" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *text = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@", text);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", [error localizedDescription]);
}];
}
提前致谢。