Securely sending email via external smtp server in cocoa touch - iphone

I'd like my app to be able to send an email, from my servers to their address, when they press a button. Seems simple enough but I can't seem to find any straightforward examples. The ones I have found use third party libraries which some people said were insecure in that someone could find a way to send their own emails through that account.
Also, would this type of thing get my app rejected? Do I have to use the built in email message window?
Thanks!

check this out: http://code.google.com/p/skpsmtpmessage/

Related

how to send email at backend of application in iPhone?

hi
I want to send an email when user open the application but that email should be sent at back end so that user can not judge that application send an email.
any body can help me?
thanx
Thanx to all of you, all of you helped me & all of you are right but i find a simple way to send an email.
The easiest way to do this thing is to write a small script on php that sends a mail & upload it on your hosting & just hit it whenever u need. You will hit the URL & it will send an email.
Simple :)
If this is for the purpose of simply knowing that someone ran the program, I would check out www.Flurry.com, free analytics for your app and very easy to integrate. (I have no connection with Flurry except as a user.)
Sending e-mail behind the scenes is not hard, necessarily, but you have to basically establish a network connection to a server that has a mail server (MTA), and then you have to "speak" SMTP to it, and a whole lot of things can go wrong in the process. :-) (I spent 10 years writing e-mail servers, so I know of what I speak. :-)
Check out Flurry. :-)
You will need to use a third party library for that. The SDK doesn't allow you to send emails in the background.
Here's one you can use:
http://code.google.com/p/skpsmtpmessage/

is it possible to send email with custom view instead of presentModalViewController

i need to send email in my application.
i know that this can be possible using MFMailComposeViewController.
But it popup presentModalViewController,I need to custom reception box,composer,subject like this.
simply by clicking send button i need to send email.
if it is possible can ant one please help me.
Thank u in advance.
For security and privacy reasons, Apple does not allow applications to send automatically email, and requires the user to review it and explicitly click on the Send button in order to do it.
If a regular app could present its own view to get the email data and send it, what's to stop a malicious app from sending spam emails on the user behalf to all his contacts?
Franci is right that Apple's frameworks do not allow this, but it can be done. You need to link in a custom SMTP framework to do it.
This is an example.
http://code.google.com/p/skpsmtpmessage/
I have not used that particular framework. Googling will probably provide many other options.
There's no background mail-sending class in Cocoa, but if you reallllly need to, you can build your own. A lot of mail servers will let you send mail anonymously. Read on up on the SMTP protocol, then pick a mail server and telnet into it and test it out. Then you can use network classes in Cocoa to follow the protocol programatically. It's a bit of a pain, but I've done it before.
Useful links:
NSStream
NSInpoutStream
NSOutputStream
SMTP protocol
To telnet into a server, pick a mail server, then in terminal, type telnet <server> 25 and press Enter. Then follow the protocol.

Can I send email programmatically in iPhone app?

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?
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.
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).
Here are a few SMTP API's that work on OS X. They might work on iOS as well.
Pantomime
MailCore
EdMessage
Only Possible via Web Interface, you can not hide the Interface , this is as per apple Guidlines to Developer and as per documentation
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!
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).
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:
RFC 5321 at https://www.rfc-editor.org/rfc/rfc5321
SMTP on Wikipedia at http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
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.

Send mail without MFMailComposeViewController

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?
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:
Open Source Cocoa/Cocoa-Touch POP3/SMTP library?
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
It is possible to use MFMailComposeViewController without user interaction. See my answer on the iPhone send email not using MessageUI question.

Anonymous SMTP Service

Does anyone know of a free, anonymous smtp service? I want to give users of my app the ability to occasionally send me an anon email without having to configure a server of enter their email account. I guess I could setup a gmail account for this purpose and embed the credentials in the app but I hope it won't be necessary. In case it sways your answer, this is a thick client (.NET Console) app.
I think that what you're asking for is called an open relay.
If there were such a thing, wouldn't it immediately be swamped by spammers?
You might be better off setting up some kind of commenting tool on your website, that sends you an email with the contents of whatever form the user submits. Then if you go that far, it shouldn't be difficult to add a form to your app that automatically makes the full HTTP request (transparent to the user, in the background).
If you run your own mail server, you can simply configure the app to deliver mail directly to it. Many web hosting companies also provide mail hosting if you don't want to run it on your own hardware. Gmail via Google Apps for your domain might be an option. It's free. But their anti-spam measures might prevent delivery. Better to have a server you can control, I think. Bottom line, though, is you don't need an anonymous SMTP relay server to get the job done.