9

I need to be able to send a pre-formatted email or SMS text message programmatically from within an iphone app. Can this be done? I have looked at apple's MFMailComposeViewController class, but this "provides a standard interface that manages the editing and sending an email message" and the MFMessageComposeViewController class also has it's own "standard system interface for composing SMS text messages". These allow you to present an interface to the user where they have to fill in all the data and then explicitly press a send button.

I cannot use this boilerplate functionality.

I need to be able to send a message without presenting any interface to the user. I know this sounds evil, but actually it is for a commercial application which needs to communicate to a user group in a central office when users in the field have performed specific actions out in the field.

Has anyone found a solution to this?

jcpennypincher
  • 3,970
  • 5
  • 31
  • 44
  • 3
    See [this answer](http://stackoverflow.com/questions/310946/how-can-i-send-mail-from-an-iphone-application/449245#449245) to [How can I send mail from an iPhone application ](http://stackoverflow.com/questions/310946/how-can-i-send-mail-from-an-iphone-application). – Matthew Flaschen Nov 07 '10 at 20:30

8 Answers8

12

After much investigation, I have found that sending emails programmatically, without user intervention, from an iphone application, cannot be implemented using any of the apple frameworks.

jcpennypincher
  • 3,970
  • 5
  • 31
  • 44
5

Set up a web service you can post to using an HTTP request. If you are posting to only one address this can work very well, although you may want to get the user to input their return mail address.

Otherwise only the standard dialog is available (this relies on using whatever account they've setup on the device).

pchap10k
  • 2,066
  • 2
  • 19
  • 30
3

Here are a few SMTP API's that work on OS X. They might work on iOS as well.

  • Pantomime
  • MailCore
  • EdMessage
Dylan Lukes
  • 935
  • 7
  • 10
1

Only Possible via Web Interface, you can not hide the Interface , this is as per apple Guidlines to Developer and as per documentation

IPhoneCrazy
  • 33
  • 1
  • 7
1

Looking for a solution to such a problem, I found something interesting here: How to send mail from iphone app without showing MFMailComposeViewController?

I hope this will be useful!

Panayot
  • 484
  • 1
  • 6
  • 18
0

I have no experience with iOS, but I have enough experience with email protocols to say I'd be very surprised if a client application could send email without accessing a server. More than likely, the email will be sent using the SMTP protocol and therefore must be sent using an SMTP server. Choosing how you connect to that server is about the only option you have. You could connect to a server-side script (such as php) to generate and send the email, or you may be able to create a socket and connect directly to port 25 on the SMTP server and still generate the email from you client application.

Check out:

Community
  • 1
  • 1
Aaron
  • 179
  • 4
  • The question doesn't say anything about not using a server. – Matthew Flaschen Nov 07 '10 at 23:36
  • "I need to be able to send a pre-formatted email...programmatically from within an iphone app. Can this be done?" Maybe I'm reading it too literally, but it sounds like he wants the app to be the thing that actually sends the message. – Aaron Nov 08 '10 at 01:39
  • Correct, this is an iphone app running on iOS4 and it needs to send the message. This cannot involve setting up a server or socket programming to another machine. However, the phone is already configured to send both emails and SMS text messages, so there is a standard email server already setup by the ISP. The question is how can a message be sent without having a user have to enter in anything? The recipient, subject, and body of the email can be prefilled yes, but how can it be sent? ...programmatically. – jcpennypincher Nov 08 '10 at 03:58
  • @jc, you have to use a server, but you don't need to set up your own. Once you know the SMTP host name, user, and password, you can use any SMTP library, including the one I linked above. The low-level socket code will be taken care of by the library. – Matthew Flaschen Nov 08 '10 at 05:02
  • Thanks for your response Matthew. I am going to try the skpsmtpmessage library located here http://code.google.com/p/skpsmtpmessage and I will post my result. It looks like exactly what I need. – jcpennypincher Nov 08 '10 at 18:00
0

This is standard not possible. If you can't use the standard dialog you need to use SMTP.

SMS is the same, use the dialog of use a webbased sms service (most of these cost some money).

Janco
  • 1,130
  • 1
  • 8
  • 15
0

You could always do a low level telnet using SMTP protocol to a known mail server to send a message. I don't know if Apple will reject the app, but SMTP is damned simple.

user756212
  • 522
  • 5
  • 16