ThinkPHP中使用SendCloud发送多个附件的邮件
随风飘扬 php 2016年07月25日14:02 4635
嗯,今天公司让我写个SendCloud的邮件类,用来给客户发送各种邮件,主要针对的是触发邮件,本来写
嗯,今天公司让我写个SendCloud的邮件类,用来给客户发送各种邮件,主要针对的是触发邮件,本来写的差不多了,但是主管跟我说要支持多附件,一看到SendCloud官网给的代码里只有一个附件的我就懵逼了。好吧,厚着脸皮上呗,首先看下一个文件和多个文件上传有什么区别
虎xaww泰gpmyq克inajo新ipw闻grm网h版权所有,请勿未授权转载!!!
虎g泰bebtd克nyjyo新qn闻nzdr网kr版权所有,请勿未授权转载!!!
这是单文件上传的
虎jahf泰xadju克dastk新dzk闻bbjor网s版权所有,请勿未授权转载!!!
虎i泰oamua克uv新pk闻rcdas网dh版权所有,请勿未授权转载!!!
这是多文件上传的
虎lwou泰m克kx新cwo闻cgcwe网ygeej版权所有,请勿未授权转载!!!
然后查看官网给的附件的案例
虎ond泰frleo克zkmd新pq闻kwe网fqot版权所有,请勿未授权转载!!!
虎tawg泰vek克w_xc新w闻cx网c版权所有,请勿未授权转载!!!
由此可知,只要遍历附件地址数组的时候重复2-6行即可
虎us泰k克ceopk新joaz闻lvfr网ayf版权所有,请勿未授权转载!!!
虎rix_x泰q克iymhh新k闻r网lqclb版权所有,请勿未授权转载!!!
其中这里需要注意的一点是分隔符,即boundary。 boundary用于作为请求参数之间的界限标识,例如参数1和参数2之间需要有一个明确的界限,这样服务器才能正确的解析到参数1和参数2。但是分隔符并不仅仅是boundary,而是下面这样的格式:-- + boundary。例如这里的boundary为 ----WebKitFormBoundaryFsA1AIs8VyxmWEZd,那么参数分隔符则为:
虎ptrns泰u_克hx新jndn闻win_网qjp版权所有,请勿未授权转载!!!
------WebKitFormBoundaryFsA1AIs8VyxmWEZd
虎y泰zvszr克p新va闻rvs_t网mm版权所有,请勿未授权转载!!!
不管boundary本身有没有这个"--",这个"--"都是不能省略的。
虎xpqn泰ia_克s新u闻o网l版权所有,请勿未授权转载!!!
而结尾的时候则是以’--‘加上----WebKitFormBoundaryFsA1AIs8VyxmWEZd加上‘--’,因此整个代码是这样子
虎xo泰zdxq克aohjt新btwd闻htntg网uwuj版权所有,请勿未授权转载!!!
虎z_q_f泰uwf克mmwi新ohnb闻qkkf网mdxbr版权所有,请勿未授权转载!!!
虎y泰mqe_k克sk新lv闻fvna网lktup版权所有,请勿未授权转载!!!
然后差不多这样了,附件是写的类
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