• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
sending emails using URLRequest and php
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sending emails using URLRequest and php


  • Subject: sending emails using URLRequest and php
  • From: Reza Farhad <email@hidden>
  • Date: Wed, 15 Apr 2009 17:45:04 +0100

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: sending emails using URLRequest and php
      • From: Danny Thuering <email@hidden>
  • Prev by Date: Re: Best way to get a non-repeating random number?
  • Next by Date: Re: Best way to get a non-repeating random number?
  • Previous by thread: Objective-C/Cocoa open source Twitter client
  • Next by thread: Re: sending emails using URLRequest and php
  • Index(es):
    • Date
    • Thread