iOS SMTP发送邮件开源项目[SKPSMTPMessage]
来源:互联网 发布:php无限极分类菜单 编辑:程序博客网 时间:2024/04/29 01:51
SKPSMTPMessage 完全不依赖于iOS系统内置的发送邮件程序,可内置于你的应用实现后台发送邮件目的。
Demo效果图:
项目地址:
github地址:https://github.com/huanghuorong/iphone-smtp
googlecode:http://code.google.com/p/skpsmtpmessage/
关键代码:
#pragma mark IBActions- (IBAction)sendMail:(id)sender { SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init]; test_smtp_message.fromEmail = fromEmail.text; test_smtp_message.toEmail = toEmail.text; test_smtp_message.relayHost = relayHost.text; test_smtp_message.requiresAuth = useAuthSwitch.on; test_smtp_message.login = login.text; test_smtp_message.pass = password.text; test_smtp_message.wantsSecure = SSLSwitch.on; // smtp.gmail.com doesn't work without TLS! test_smtp_message.subject = subject.text;// test_smtp_message.bccEmail = @"testbcc@test.com"; // Only do this for self-signed certs! // test_smtp_message.validateSSLChain = NO; test_smtp_message.delegate = self; NSMutableArray *parts_to_send = [NSMutableArray array]; //If you are not sure how to format your message part, send an email to your self. //In Mail.app, View > Message> Raw Source to see the raw text that a standard email client will generate. //This should give you an idea of the proper format and options you need NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:plain_text_part]; if (sendVCFSwitch.on) { NSString *vcard_path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"vcf"]; NSData *vcard_data = [NSData dataWithContentsOfFile:vcard_path]; NSDictionary *vcard_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"test.vcf\"",kSKPSMTPPartContentTypeKey, @"attachment;\r\n\tfilename=\"test.vcf\"",kSKPSMTPPartContentDispositionKey, [vcard_data encodeBase64ForData],kSKPSMTPPartMessageKey, @"base64",kSKPSMTPPartContentTransferEncodingKey,nil]; [parts_to_send addObject:vcard_part]; } if (sendImageSwitch.on) { NSString *image_path = [[NSBundle mainBundle] pathForResource:@"Success" ofType:@"png"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @"inline;\r\n\tfilename=\"Success.png\"",kSKPSMTPPartContentDispositionKey, @"base64",kSKPSMTPPartContentTransferEncodingKey, @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil]; [parts_to_send addObject:image_part]; } NSDictionary *sig_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [@"\n" stringByAppendingString:sig.text], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:sig_text_part]; test_smtp_message.parts = parts_to_send; Spinner.hidden = NO; [Spinner startAnimating]; ProgressBar.hidden = NO; HighestState = 0; [test_smtp_message send];}
参考:IOS开发中发送Email的两种方法
http://blog.sina.com.cn/s/blog_94d94f1a01016rgc.html
- iOS SMTP发送邮件开源项目[SKPSMTPMessage]
- iOS SMTP发送邮件开源项目[SKPSMTPMessage]
- skpsmtpmessage——Quick SMTP邮件发送
- iOS使用 [SKPSMTPMessage]发送邮件
- 使用iOS开源库SKPSMTPMessage实现邮件发送
- 使用iOS开源库SKPSMTPMessage实现邮件发送
- 使用iOS开源库SKPSMTPMessage实现邮件发送
- iOS-静默方式发送邮件(SKPSMTPMessage)
- SKPSMTPMessage发送邮件小解
- SKPSMTPMessage实现邮件发送
- iOS开发—邮件发送第三方SKPSMTPMessage 新解
- C#发送SMTP邮件
- SMTP发送邮件
- .net smtp发送邮件
- 使用SMTP发送邮件
- smtp邮件发送
- 用SMTP发送邮件
- MailMessage、Smtp发送邮件
- hive删除包含较多分区表有错误
- Linux内核分析系列摘自http://www.cnblogs.com/hanyan225/category/308793.html
- C#中利用反射操作私有字段与私有方法
- hive使用压缩时出现的问题
- nlpers上面关于自然语言处理(NLP)如何入门的文章
- iOS SMTP发送邮件开源项目[SKPSMTPMessage]
- LWIP netbuf netconn函数
- 调试器工作原理——基础篇
- python: https client sample
- linux MISC 驱动模型分析
- Canvas学习笔记二——图形绘制
- android布局与多屏适配---layout_weight
- python中的迭代器
- 2012年度总结