Re: sending emails using URLRequest and php
Re: sending emails using URLRequest and php
- Subject: Re: sending emails using URLRequest and php
- From: Reza Farhad <email@hidden>
- Date: Wed, 15 Apr 2009 18:04:20 +0100
Danny
That is what I did think initially and I tried that, but did not have
any luck. If open the php page in safari I do get a mail sent but not
if I try it from my code.
Reza
On 15 Apr 2009, at 17:54, Danny Thuering wrote:
Hi,
You have to set the URL of your request to the URL of your php. Not
to the URL of your HTML page.
Bye
Danny
Sent from iPhone
On 15.04.2009, at 18:45, Reza Farhad <email@hidden> wrote:
dear all
I am looking at using URLRequest and php to configure my app to
send an email by sending a post to a form and then the form sending
me an email. I have very little understanding of this process and
any help would be appreciated. I know this has been discussed
here before, but I think my issues are much more basic to previous
posts, and I need help.
I have setup a form called phpForm.html with one message field, the
html code is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="post" action="sendInfo.php">
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>
</body>
</html>
now my code sendInfo.php is:
<?php
$message = $_REQUEST['message'] ;
mail( "email@hidden", "Test Message", $message );
?>
and this works when I open the page in safari and send the form
now in my code I have the following:
-( 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/phpForm.html
"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded"
forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
}
unfortunately nothing seems to happen. Do I have to communicate
with the php script directly, and if so how?
Thanks
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:
@gmail.com
This email sent to email@hidden
_______________________________________________
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