views:

134

answers:

2

Hi there,

I am trying to send mail using MFMailComposeViewController. Everything works, except that mails do not get sent, and I always get MFMailComposeResultFailed.

Any pointers? I am NOT using the simulator, and sending mail does work from my device. I do have a connection (testing via Reachability), and [MFMailComposeViewController canSendMail] returns YES.

No compiler warnings in the project, no crashes...

Thank you in advance. JT

A: 

It's difficult to tell without seeing a code snippet, however you should check the following:

1) you have correctly set the MFMailComposeViewController's delegate and implemented its delegate methods;

2) you have set the mail subject using setSubject:

3) you have set the message body using setMessageBody:isHTML:

and optionally set an attach using addAttachmentData:mimeType:fileName:

4) you have presented to the user your mail compose view controller using something like

[self presentModalViewController:mcvc animated:YES];

Hope this helps.

unforgiven
Yeah, I had done all that correctly. Turns out it was a bug in the OS. See my answer below.Thank you anyway :)
Joseph Tura
+2  A: 

It was a bug in IOS4.

I had both an Exchange mail account and an old, inactive IMAP account on my phone. Apparently, that leads to problems with iOS4. The mails actually were stuck in the outbox. Once I remove the inactive IMAP account, everything worked as expected.

Joseph Tura