How to send email from iPhone app without user interface

那年仲夏 提交于 2019-12-08 12:59:44

问题


I want my app to be able to send an email with attachment to a hard-coded recipient with no user input required, unlike the MessageUI framework.

Is there any way to do this? Any example code would be appreciated.

Thanks in advance.


回答1:


As Saurabh said, there is no low level mail library. I would look for an SMTP library, rather than an IMAP one, because you don't need to get mail, just sent it.

Attachments can be done with MFMailComposeViewController's via -(void)addAttachmentData:(NSData *)attachment mimeType:(NSString *)mimeType fileName:(NSString *)filename

Which I believe simply base64 encodes the data, and attached a mime type header and footer.

Check out this question for lots on the topic: Open Source Cocoa/Cocoa-Touch POP3/SMTP library?




回答2:


Apple doesn't give you a way to do this. You'll have to write your own IMAP library or use a 3rd-party library (Mailcore is good).



来源:https://stackoverflow.com/questions/2080278/how-to-send-email-from-iphone-app-without-user-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!