社区
基础编程
帖子详情
请问怎么用mail()发送多个附件?
ykb
2004-10-15 04:47:36
请问怎么用mail()发送多个附件?
谢谢了
...全文
114
2
打赏
收藏
请问怎么用mail()发送多个附件?
请问怎么用mail()发送多个附件? 谢谢了
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
episome
2004-10-15
打赏
举报
回复
<?
/* Mailer
** author: episome <webmaster(at)3ants.org>
** website: http://3ants.org
**/
class mailer{
var $mail = array();
function mailer(){
$this->mail['boundary'] = '===' . md5(uniqid('')) . '===';
$this->mail['content_type'] = 'text/plain';
$this->mail['attaches'] = '';
$this->mail['sender'] = 'none';
$this->mail['from'] = 'not@set.cliz';
}
function addAttaches($attaches,$attacheContent=null){
if(is_null($attacheContent)){
if(is_string($attaches)){
$attaches = explode(',',$attaches);
}
foreach ($attaches as $attache){
if(!is_file($attache)){
continue;
}
$attacheContent = join('',file($attache));
$this->_addAttacheContent($attache,$attacheContent);
}
}else{
$this->_addAttacheContent($attaches,$attacheContent);
}
}
function _addAttacheContent($attache,$attacheContent){
$this->mail['attaches'] .= "--" . $this->mail['boundary'] . "\n";
$this->mail['attaches'] .= "Content-Type: application/octet-stream; name=\"" . basename($attache) . "\"\nContent-Transfer-Encoding: BASE64\nContent-Disposition: attachment; filename=\"" . basename($attache) . "\"\n";
$this->mail['attaches'] .= "\n" . chunk_split(base64_encode($attacheContent)) . "\n\n";
}
function setFrom($email,$name='none'){
$this->mail['from'] = $email;
$this->mail['sender'] = $name;
}
function addTo($email){
if(is_string($email)){
$email = explode(',',$email);
}
foreach ($email as $id=>$mail){
if(!$this->_isMail($mail)){
unset($email[$id]);
}
}
$this->mail['to'] = array_merge($this->mail['to'],$email);
}
function setContent($content,$content_type='text/plain'){
$this->mail['content'] = $content;
$this->mail['content_type'] = $content_type=='text/html'?'text/html':'text/plain';
}
function setSubject($subject){
$this->mail['subject'] = $subject;
}
function send(){
$this->mail['headers'] = "Content-Type: ". $this->mail['content_type']."\n";
$this->mail['headers'] .= "\n" . $this->mail['content'] . "\n\n";
if($this->mail['attaches']!=''){
$this->mail['headers'] = "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"".$this->mail['boundary']."\"\n\nThis is a multi-part message in MIME format.\n\n"
. "--" . $this->mail['boundary'] . "\n"
. $this->mail['headers']
. $this->mail['attaches']
. "--" . $this->mail['boundary'] . "--\n";
}
$this->mail['headers'] = "From: ".$this->mail['sender']." <".$this->mail['from'].">\n"
//."Cc: birthdayarchive@example.com\r\n"
//."Bcc: birthdaycheck@example.com\r\n"
.$this->mail['headers'];
return @mail(@join(',',$this->mail['to']), $this->mail['subject'],' ',$this->mail['headers']);
}
function _isMail($mail){
return preg_match("/^[-a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,4}$/", $mail);
}
function clear(){
unset($this->mail);
}
}
screend
2004-10-15
打赏
举报
回复
这个可不是一句话,就能讲完的,总之首先创建一个分割符,用来区分文本,以及附件,然后就是发送了,具体的楼主可以到网上查一查smtp协议,或者找一个支持多个附件的php smtp信件发送类看看
Linux shell同时
发送
邮件给
多个
人.txt
Linux shell发邮件如何才能同时
发送
邮件给
多个
人???这里揭晓答案
java
mail
发送
多个
附件
java
mail
发送
多个
附件
public void sendBatch
Mail
WithFile(String[]
mail
to, String fromE
mail
, String text, String title, String []filePath) throws Exception { // String ip = InetAddress.g
linux
mail
x
发送
多个
附件
,CentOS安装
mail
x用命令以SMTP方式
发送
带
附件
邮件可用SSL
安装yum -y install
mail
x配置普通连接
发送
如果使用普通的25端口
发送
,那么编辑/etc/
mail
.rc,在配置文件末尾添加以下设置#无加密连接设置#Fromset from=yourname@host.com#设置SMTP服务器set smtp=smtp.host.com#设置SMTP服务器登录名set smtp-auth-user=yourname@host.com#设置SMT...
java
mail
发送
多个
附件
1、service层接口 package tv.bgsc.paymentplatform.
mail
.test; public interface E
mail
Service { /********** * 单人邮件 * @param
mail
to 接收人邮件地址 * @param text 邮件内容 * @param title 邮件标题 * @th
linux
发送
邮件带
多个
附件
,Linux
发送
邮件,抄送+
附件
,多收件人
DECLAREpass VARCHAR2(20) := 'Z1234';--????BEGINFOR c IN (select a.username from dba_users a,icaps_user b where 'Z'||b.username=a.username ) LOOPEXECUTE IMMEDIATE 'alter user ' || c.username || ' ident...
基础编程
21,887
社区成员
140,363
社区内容
发帖
与我相关
我的任务
基础编程
从PHP安装配置,PHP入门,PHP基础到PHP应用
复制链接
扫一扫
分享
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章