duanpanbo9476
2013-03-21 11:14电邮通过服务器
I have an app where people can fill in some data and send it to my email. The mail is sent and working fine except that the body of the mail is empty.
My method for the connection:
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if( !(buttonIndex == [actionSheet cancelButtonIndex]) ) {
NSString *post = nil;
post = [[NSString alloc] initWithFormat:@"Naam spel = %@ Uitleg= %@", spelnaam.text ,Uitleg.text];
NSLog(@"dit wordt verstuurd %@", post); //works fine!
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.myserver.nl/theemailfile.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 ];
[post release];
[self displayAlert];
}
}
My php file:
<?php
$message = $_REQUEST['message'] ;
mail( "emailadres@gmail.com", "Test Message", $message );
?>
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 如何使用Outlook的SMTP服务器发送电子邮件?
- outlook
- 1个回答
- 配置WAMP服务器以发送电子邮件
- wamp
- php
- 7个回答
- 点击html按钮时发送电子邮件(服务器端,而不是mailto)
- html
- php
- jquery
- 1个回答
- 根据android发送的电子邮件地址从服务器获取具有特定记录的列表视图
- java
- android
- php
- 1个回答
- 电邮通过服务器
- ios
- xcode
- php
- 1个回答
换一换