ThinkPHP中使用SendCloud发送多个附件的邮件
随风飘扬 php 2016年07月25日14:02 6769
嗯,今天公司让我写个SendCloud的邮件类,用来给客户发送各种邮件,主要针对的是触发邮件,本来写
嗯,今天公司让我写个SendCloud的邮件类,用来给客户发送各种邮件,主要针对的是触发邮件,本来写的差不多了,但是主管跟我说要支持多附件,一看到SendCloud官网给的代码里只有一个附件的我就懵逼了。好吧,厚着脸皮上呗,首先看下一个文件和多个文件上传有什么区别
虎nw泰p克cqqhf新bllpw闻hjxgr网k_td版权所有,请勿未授权转载!!!

虎f泰_k克d新sckr闻lzskw网z版权所有,请勿未授权转载!!!
这是单文件上传的
虎h泰gwy克pd新lqglt闻q_pk网zx版权所有,请勿未授权转载!!!

虎h泰fo克c新lc闻ezei网wvvnh版权所有,请勿未授权转载!!!
这是多文件上传的
虎rfi泰c克vuf新_boo闻tst网upgz版权所有,请勿未授权转载!!!
然后查看官网给的附件的案例
虎uass泰myxg克yfbu新q闻_ie网xajx版权所有,请勿未授权转载!!!

虎d泰okgs克zkdqt新t闻f网gz版权所有,请勿未授权转载!!!
由此可知,只要遍历附件地址数组的时候重复2-6行即可
虎am泰woail克qbdw新rig闻sqekf网ndha版权所有,请勿未授权转载!!!

虎fklr泰m_克kqvj新tj闻kq网tmnem版权所有,请勿未授权转载!!!
其中这里需要注意的一点是分隔符,即boundary。 boundary用于作为请求参数之间的界限标识,例如参数1和参数2之间需要有一个明确的界限,这样服务器才能正确的解析到参数1和参数2。但是分隔符并不仅仅是boundary,而是下面这样的格式:-- + boundary。例如这里的boundary为 ----WebKitFormBoundaryFsA1AIs8VyxmWEZd,那么参数分隔符则为:
虎ssaf泰isn克zjku新izay闻xdzx网ihtm版权所有,请勿未授权转载!!!
------WebKitFormBoundaryFsA1AIs8VyxmWEZd
虎v泰nelp克d新ryix闻zhjg网l版权所有,请勿未授权转载!!!
不管boundary本身有没有这个"--",这个"--"都是不能省略的。
虎gerr泰sdz克apbh新wy闻opipb网nj版权所有,请勿未授权转载!!!
而结尾的时候则是以’--‘加上----WebKitFormBoundaryFsA1AIs8VyxmWEZd加上‘--’,因此整个代码是这样子
虎m泰byv克s新_闻ie网lrlds版权所有,请勿未授权转载!!!

虎tny泰bvh克q新toffd闻ddyqv网vcjli版权所有,请勿未授权转载!!!
虎n泰hq克g新ab闻knx网oda版权所有,请勿未授权转载!!!
然后差不多这样了,附件是写的类
Statement: all articles / drawings reproduced on this website are for the purpose of transmitting more information and facilitating discussion, which does not mean that the website, the host and the organizer agree with their opinions or confirm the authenticity of their contents. The contents of the articles are for reference only. If the rights of the original author are violated, please contact the website administrator.
Comment list
-
No data