资源描述:
《发送邮件方法》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、发送邮件方法/***邮件发送**@param:$user_name[string]接收人姓名*@param:$email_addr[string]接收人邮件地址*@param:$title[string]邮件标题*@param:$content[string]邮件内容*@param:$type[int]0普通邮件,1HTML邮件*@param:$notification[bool]true要求回执,false不用回执**@returnboolean*/functionsend_mail($user_
2、name,$email_addr,$title,$content,$type=0,$notification=false){/*如果邮件编码不是EC_CHARSET,创建字符集转换对象,转换编码*/if($GLOBALS['_CFG']['mail_charset']!=EC_CHARSET){$name=ecs_iconv(EC_CHARSET,$GLOBALS['_CFG']['mail_charset'],$name);$subject=ecs_iconv(EC_CHARSET,$GLOBAL
3、S['_CFG']['mail_charset'],$subject);$content=ecs_iconv(EC_CHARSET,$GLOBALS['_CFG']['mail_charset'],$content);$GLOBALS['_CFG']['shop_name']=ecs_iconv(EC_CHARSET,$GLOBALS['_CFG']['mail_charset'],$GLOBALS['_CFG']['shop_name']);}$charset=$GLOBALS['_CFG']['
4、mail_charset'];/***使用mail函数发送邮件*/if($GLOBALS['_CFG']['mail_service']==0&&function_exists('mail')){/*邮件的头部信息*/$content_type=($type==0)?'Content-Type:text/plain;charset='.$charset:'Content-Type:text/html;charset='.$charset;$headers=array();$headers[]='Fr
5、om:"'.'=?'.$charset.'?B?'.base64_encode($GLOBALS['_CFG']['shop_name']).'?='.'"<'.$GLOBALS['_CFG']['smtp_mail'].'>';$headers[]=$content_type.';format=flowed';if($notification){$headers[]='Disposition-Notification-To:'.'=?'.$charset.'?B?'.base64_encode($
6、GLOBALS['_CFG']['shop_name']).'?='.'"<'.$GLOBALS['_CFG']['smtp_mail'].'>';}$res=@mail($email,'=?'.$charset.'?B?'.base64_encode($subject).'?=',$content,implode("r",$headers));if(!$res){$GLOBALS['err']->add($GLOBALS['_LANG']['sendemail_false']);return
7、false;}else{returntrue;}}/***使用smtp服务发送邮件*/else{/*邮件的头部信息*/$content_type=($type==0)?'Content-Type:text/plain;charset='.$charset:'Content-Type:text/html;charset='.$charset;$content=base64_encode($content);$headers=array();$headers[]='Date:'.gmdate('D,jM
8、YH:i:s').'+0000';$headers[]='To:"'.'=?'.$charset.'?B?'.base64_encode($name).'?='.'"<'.$email.'>';$headers[]='From:"'.'=?'.$charset.'?B?'.base64_encode($GLOBALS['_CFG']['shop_name']).'?='.'"<'.$GLOBALS['_CFG']['smtp_mail'].'>';$headers[]