I have a question about the MFMailComposeViewController for sending an Email in an app. Is it possible to check the recipient adress before sending the email ?
I did not find any response so i think it's not possible..
If it's not possible, there is other solution ?
When you present the MFMailComposeViewController you lose complete control over it.
You can't do anything with it, neither get the "To" email address nor prevent the sending of the mail.
From the documentation:
Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.
Related
I'm using UIActivityViewController and when the user selects email from the list of options is there a way to save the email recipients that the user inputs?
Do I need to subclass ActivityItemSource as was done here?
I realize getting the email recipients is tricky even with just using MFMailcomposeViewController as in here.
Do I need to subclass MFMailcomposeViewController to save the email recipients that the user inputs?
From the class reference:
Important: The mail composition interface itself is not customizable
and must not be modified by your application. In addition, after
presenting the interface, your application is not allowed to make
further changes to the email content. The user may still edit the
content using the interface, but programmatic changes are ignored.
Thus, you must set the values of content fields before presenting the
interface.
So, no. You should not subclass MFMailcomposeViewController in order to "steal" the email addresses that the user has entered. This is a privacy issue, and Apple specifically designed it this way. If you try to circumvent this, then your app very likely will be (and should be) rejected.
First of all, I'm working on an in-house app, so I don't need approval at App Store. I know it wouldn't ever be accepted, but it's a business rule our users share some content of the application, but with a default message and subject, so they can't edit these fields..
Until iOS 5 I was able to navigate by the view hierarchy and let the fields unneditable. But with iOS 6, and the mail on another proccess, I can't do it anymore.
I need to block the views for editing (I put a view over all the mail view, except the title bar, and it works, but when the user try to cancel the e-mail, my view is blocking the popover to delete or save draft too) or send e-mails without the UI (I was able to do it with Stealth Messenger based code (https://github.com/0xced/Stealth-Messenger/) at iOS 4 or 5, but now it doesn't work).
I tryed everything I could with private APIs and Objective-C runtime.. I can dismiss the view with sending e-mail ok, but the e-mail itself isn't sent.
Can anybody help me? Does anybody did it?
Thanks in advance..
Take a look at this: Send Email in Background from iOS
IOS doesn't support to mail in background. [...] As an alternate you
should implement the WebService for this[...]
Probably the best option is to utilise some server code and call that with NSURLRequest.
Hope that helps.
I do this in an app of mine. I have a simple PHP script on a webserver that uses the PearPHP mail modules to send SMTP mail. The PHP script takes a few incoming variables, like $toAddress, $subject, $message and then connects to the SMTP server and sends the mail out.
Unfortunately, you're not allowed to subclass the MFMailComposeViewController, and if you were using some sort of Invisible UIView to block fields, that was just a workaround that's probably been broken. (They did the same thing with being able to insert a "." on the NumberPad keyboard)
Ok, so I have successfully made my first in-app Email app using MFMAilComposer. I have the toRecipients textfield added, as well as subject and body etc. So I understand that the email will not send if I use the simulator and will send with an iPhone. However, when a person receives the email, how is that person supposed to know whom he received it from? With this in mind, a "From" field should be in order. I appreciate all answers, and thanks in advance :)
You don't have to handle this, the mail composer does it for you. When the composer is shown it defaults to the users default email account but if they want to choose which email address they are sending from they can simply tap their email and a list will expand allowing them to choose from which of their emails to send the message.
I need to work on an application able to send a mail with automatic content (subject/text) that the user shouldn't be allowed to edit. Is it possible to do ?
Thanks for your advices
The answer is "no". If you want to use the MFMailComposeViewController class, you have to pay attention to this paragraph in Apple's documentation:
Important The mail composition interface itself is not customizable
and must not be modified by your application. In addition, after
presenting the interface, your application is not allowed to make
further changes to the email content. The user may still edit the
content using the interface, but programmatic changes are ignored.
Thus, you must set the values of content fields before presenting the
interface.
The user can (and should be able to) change anything and everything s/he wishes before they send out an e-mail.
If you don't want to follow those rules Apple set, there are other mail frameworks you can use within your iOS app.
I want to attach a video and send email from my application.
I downloaded apples example code MailComposer. I compiled it. I did not get any errors or warnings.
I sent the mail to my mail id. But, I could not see any mail in my inbox. I am working on simulator.
I did not set any senders email id in simulator.
How can I know whether the code is working or not ?
Thank You.
The simulator cannot send email; nor can all devices, as you'll discover if you use the MFMailComposeViewController +canSendMail method—it returns NO if the device doesn't have a mail account set up. To quote the documentation:
You should call this method before attempting to display the mail composition interface. If it returns NO, you must not display the mail composition interface.