0

In my app, my user fills out first name and email fields. I want to send this data to an email address when the user taps the "Submit" button, but the only way I can seem to do that is by having the Apple Mail client open. Right now, I'm using the following code - is there a way to send field data to a specific email address without launching Apple Mail? E.g. user taps "submit", and gets pushed to a "Thank You" view?

MFMailComposeViewController *mail =[[MFMailComposeViewController alloc] init];
NSString *emailbody = email.text;
NSString *firstnamebody = firstName.text;

[mail setMessageBody:emailbody isHTML:NO];
[mail setMessageBody:firstnamebody isHTML:NO];
Brittany
  • 1,359
  • 4
  • 24
  • 63
  • Do you want the email sent from the user's email address or can it be from yours? – rmaddy Feb 10 '16 at 00:02
  • @rmaddy Preferably from the user's email address (pulled from the email field). – Brittany Feb 10 '16 at 00:03
  • Then it can't be done. You need to use `MFMailComposeViewController` (or launch the Mail app) to have the email be sent from the user's email address. – rmaddy Feb 10 '16 at 00:04
  • @rmaddy Lame - haha. What if I'm fine with it coming from my own specified email address? – Brittany Feb 10 '16 at 00:04
  • Then see http://stackoverflow.com/questions/9427056/how-to-send-mail-from-iphone-app-without-showing-mfmailcomposeviewcontroller – rmaddy Feb 10 '16 at 00:05
  • It's not lame. It's to prevent a 3rd party app from sending SPAM from user's devices under their email address. It's a good thing. – rmaddy Feb 10 '16 at 00:06

1 Answers1

2

Only if you send the data to some server and the server sends the email for you. This could be your server or a 3rd party service you use (via a REST interface probably).

Wain
  • 118,658
  • 15
  • 128
  • 151