Xcode 4/iOS - 从我的应用程序内部使用 SMTP 发送电子邮件 [英] Xcode 4 / iOS - Send an email using SMTP from inside my app

查看:90
本文介绍了Xcode 4/iOS - 从我的应用程序内部使用 SMTP 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一个框架,以允许我从我的应用程序内部发送电子邮件.我尝试过 MailCore、Pantomime 和 SKPSMTP,但都没有成功.我无法让它们在 Xcode 中编译,所以我认为它们已经过时了.有什么办法可以做到这一点吗?如果是这样,如何?谢谢.

I've been looking around for a framework to simply allow me to send an email from inside my app. I have tried MailCore, Pantomime and SKPSMTP all with no luck. I can't get them to compile in Xcode, so I presumed they were outdated. Is there any way I can do this? If so, how? Thanks.

推荐答案

您可以轻松地从 iOS 设备发送电子邮件.无需实施 SMTP 等.在 iOS 中使用内置电子邮件功能的最大好处是它可以让您访问地址簿!因此它会自动完成姓名、电子邮件地址.啊啊啊!!

You can easily send emails from your iOS device. No need to implement SMTP and all. Best thing about using inbuilt emailing facilities in iOS is it gives you access to the address book! So it auto-completes names, email addresses. Yaaiiii!!

包括,AddressBookAddressBookUIMessageUI 框架并编写类似这样的代码.请注意,您甚至可以选择以 HTML 格式发送内容!

Include, AddressBook,AddressBookUI and MessageUI frameworks and code something like this. Note you can even choose to send content as HTML too!

#import <MessageUI/MessageUI.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>

MFMailComposeViewController *mailComposer; 
mailComposer  = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setModalPresentationStyle:UIModalPresentationFormSheet];
[mailComposer setSubject:@"your custom subject"];
[mailComposer setMessageBody:@"your custom body content" isHTML:NO];
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];

为了完整起见,如果用户按下cancelsend -

For the sake of completeness, I have to write this selector to dismiss the email window if the user presses cancel or send -

- (void)mailComposeController:(MFMailComposeViewController*)controller 
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError*)error 
{ 
    if(error) NSLog(@"ERROR - mailComposeController: %@", [error localizedDescription]);
    [self dismissModalViewControllerAnimated:YES];
    return;
}

快乐编码...

这篇关于Xcode 4/iOS - 从我的应用程序内部使用 SMTP 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆