zoukankan      html  css  js  c++  java
  • iOS开发笔记--iOS后台发送邮件

    skpsmtpmessage 是ios第三方后台发送邮件库 https://github.com/jetseven/skpsmtpmessage.git

    原文地址:http://www.cnblogs.com/U-tansuo/p/ios_send_email.html

    -(void)statrUpLoad:(id)sender
    {
        SKPSMTPMessage *testSend = [[SKPSMTPMessage alloc]init];
        testSend.fromEmail = @"发件邮箱";
        testSend.toEmail = @"收件邮箱";
        testSend.relayHost = @"smtp.163.com";
        testSend.requiresAuth = YES;
        testSend.login = @"用户名;
        testSend.pass = @"密码;
        testSend.subject = [NSString stringWithCString:"测试" encoding:NSUTF8StringEncoding];
        testSend.ccEmail = @"抄送邮件";
        testSend.wantsSecure = YES;
        testSend.delegate = self;
        
        NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
                                   @"This is a tést messåge.",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
        
        NSString *vcfPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"vcf"];
        NSData *vcfData = [NSData dataWithContentsOfFile:vcfPath];
        //通讯录
        NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/directory; x-unix-mode=0644; name="test.vcf"",kSKPSMTPPartContentTypeKey,
                                 @"attachment; filename="test.vcf"",kSKPSMTPPartContentDispositionKey,[vcfData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
        //发图片附件
          NSString *imgPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"];
        NSData *imgData = [NSData dataWithContentsOfFile:imgPath];
        NSDictionary *imagePart = [NSDictionary dictionaryWithObjectsAndKeys:@"image/jpg; x-unix-mode=0644; name="test.jpg"",kSKPSMTPPartContentTypeKey,
                                   @"attachment; filename="test.jpg"",kSKPSMTPPartContentDispositionKey,[imgData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
        //发视频附件
        //attach video
        NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mov"];
        NSData *videoData = [NSData dataWithContentsOfFile: videoPath];
        NSDictionary *videoPart = [NSDictionary dictionaryWithObjectsAndKeys:@"video/quicktime; x-unix-mode=0644; name="video.mov"",kSKPSMTPPartContentTypeKey,
                                   @"attachment; filename="video.mov"",kSKPSMTPPartContentDispositionKey,[videoData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
        
        testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart, imagePart, videoPart, nil];
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [testSend send];
        });
    }

  • 相关阅读:
    php 仿百度文库
    Linux PHP实现仿百度文库预览功能
    linux下设置环境变量
    Nginx出现413 Request Entity Too Large错误解决方法
    python例子-urllib,urllib2练习题合集.
    linux问题-CentOS7和以往版本的变化
    linux问题-CentOS7中搭建HTTP,FTP服务,改变提示颜色
    shell脚本编程-例子_使用expect下载ftp文件
    centos中安装rpm包报错——No KEY
    shell脚本编程-例子_服务器存活监控
  • 原文地址:https://www.cnblogs.com/ios4kerwin/p/4532838.html
Copyright © 2011-2022 走看看