sending emails using URLRequest and php
sending emails using URLRequest and php
- Subject: sending emails using URLRequest and php
- From: Reza Farhad <email@hidden>
- Date: Thu, 16 Apr 2009 10:26:20 +0100
dear all
The issue has now been solved so here is the solution for all those
that are interested:
You need to make your URL request pointing to your php script:
and through my frustration I had forgotten to add the call to get URL
request sent out with URLConnection
so here it is in full
The script sendInfo.php:
<?php
$message = $_REQUEST['message'] ;
mail( "email@hidden", "Test Message", $message );
?>
and here is the code section in my cocoa app:
-( IBAction ) sendMail:( id )sender
{
NSString *post = @"message=testing";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding
allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData
length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init]
autorelease];
[request setURL:[NSURL URLWithString:@"http://www.qu-s.eu/
sendInfo.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded"
forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[ NSURLConnection connectionWithRequest:request delegate:self ];
}
Thanks again to all and may I again refer interested people to this
blog which has more information
http://deusty.blogspot.com/search/label/NSURLRequest
Reza
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden