18

I want to send mail from an iPhone app without showing an MFMailComposeViewController. I also want this mail to be sent from the user's default Mail account. Is it possible to do this?

Jonathan Sterling
  • 18,320
  • 12
  • 67
  • 79
  • Do you mean that you want to send an email without requiring a confirmation from the user? – notnoop Aug 11 '09 at 22:52
  • 4
    You can't do that legally. Use MFMailComposeViewController. – Jason Coco Aug 11 '09 at 23:09
  • No, what I meant was for the user to be able to use a customized mail form instead of the built-in MFMailComposeViewController; I wanted this because I have added functionality that is not supported under MFMailComposeViewController. It isn't like I wanted to spam people. – Jonathan Sterling Aug 12 '09 at 03:01
  • You can get whatever you want however you want it from your user and then use that information to pre-poulate things in the form, however, it's clearly documented that you cannot change or modify the form or interact with it in any other way. In fact, attempting to modify anything in the form after you display it will result in an exception being thrown. – Jason Coco Aug 12 '09 at 15:35

3 Answers3

16

This is not supported by the iPhone SDK, probably because Apple doesn't want you to do it.

Why not? My guess: Because it's easy to abuse. If we knew user's email address, we could spam them, we could fake emails from them, etc. Imagine finding out an iPhone app sent an email as you without your knowledge -- not cool, even if the app had good intentions.

So, anything you do to get around that, is likely to get you rejected from the app store.

Having said all that, you could basically write your own smtp interaction code to chat with the user's outgoing mail server. For example, if the user has a gmail account, you could ask them for their email and password, you'd have to know how to talk to the gmail servers, and send email through them.

Going that route means asking the user for their username, password, and either asking for or figuring out their mail server information. Another choice is to send directly from the phone (your own smpt server, not just a client), which is a bit more coding. And if you write your own server, the mail you send is more likely to be blocked since your originating IP might not match the domain on the sender's email.

There also exist some libraries that might help out. Previous related question:

Community
  • 1
  • 1
Tyler
  • 28,498
  • 11
  • 90
  • 106
4

There are legitimate reasons for wanting to send an email. (Such as communicating with a server using SMTP instead of HTTP)

This blog post should get you going: http://vafer.org/blog/20080604120118

corydoras
  • 7,130
  • 12
  • 55
  • 58
  • Yes, thank you. People seem to think that I just want to spam folks. What if I want a built-in way to send feedback? Not all email w/o MFMailComposeViewController is malicious. – Jonathan Sterling Aug 12 '09 at 03:01
  • yes there are legitimate reasons why people want to do this. for example the device could send an email if the device is not plugged in, someone plays around with an ipad displayed in a store, takes out the chord. – Zsolt Jun 17 '13 at 12:52
1

It is possible to use MFMailComposeViewController without user interaction. See my answer on the iPhone send email not using MessageUI question.

Community
  • 1
  • 1
0xced
  • 25,219
  • 10
  • 103
  • 255