Xcode通过PHP发送邮件。发送失败不会产生错误

时间:2012-07-25 07:11:14

标签: xcode forms email quickdialog

任何人都可以帮我解决这个相当大的问题。 我有一个我用QuickDialog设计的预订表格,它使用我的网络服务器上的mail()函数向php文件发送请求以发送电子邮件。这一切都运作良好,直到出现错误。如果我从我的网站上删除php文件或禁用互联网,当按下发送按钮时,它表示预订已发送,当它显然不是。我不记得我的代码在哪里,也许是错的?

P.S,我正在使用故事板。

QButtonElement *button = [[QButtonElement alloc] initWithTitle:@"Submit Booking"];
button.onSelected = ^{

    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [root fetchValueIntoObject:dict];

    NSString *msg = @"Values:";
    for (NSString *aKey in dict){
        msg = [msg stringByAppendingFormat:@"\n- %@: %@", aKey, [dict valueForKey:aKey]];
    }


    NSLog(@"%s", __FUNCTION__);
    //Allocate NSURL object
    NSURL *nsURL = [[NSURL alloc] initWithString:kTextUrl];
    // Allocate NSMutableURLRequest
    NSMutableURLRequest *nsMutableURLRequest = [[NSMutableURLRequest alloc] initWithURL:nsURL];
    // Set HTTP method to POST
    [nsMutableURLRequest setHTTPMethod:@"POST"];

    // Set up the parameters to send.
    NSString *paramDataString = [NSString stringWithFormat:@"fname=%@&lname=%@&email=%@&mnumber=%@&treatment1=%@&datetime=%@&altdatetime=%@&therapist=%@&contactMethod=%@", fname.textValue, lname.textValue, email.textValue, mnumber.textValue, treatment1.selectedItems, datetime.textValue, altdatetime.textValue, therapist.textValue, contactMethod.selectedItem];
    NSLog(@"%s - paramDataString: %@", __FUNCTION__, paramDataString);
    // Encode the parameters to default for NSMutableURLRequest.
    NSData *paramData = [paramDataString dataUsingEncoding:NSUTF8StringEncoding];
    // Set the NSMutableURLRequest body data.
    [nsMutableURLRequest setHTTPBody: paramData];   
    // Create NSURLConnection and start the request.
    NSURLConnection *nsUrlConnection=[[NSURLConnection alloc]
                                      initWithRequest:nsMutableURLRequest 
                                      delegate:self];
    // Successful connection.
    if (nsUrlConnection) {
    [self performSegueWithIdentifier: @"segueSuccess" sender: self];

    }
    // Unsuccessful connection.
    else {

    [self performSegueWithIdentifier: @"segueFail" sender: self];
    }

};

nsURL在头文件中定义。

0 个答案:

没有答案