当前位置: 首页 > news >正文 asp Jmail发邮件类 news 来源:原创 2024/5/20 9:48:49 <!--#include file="conn.asp" --> <!--#include file="Fun.asp" --> <% '发送邮件类 class SendEmails '发送 private flag private info public sub Class_Initialize() flag=false info="" end sub public sub Class_Terminate() flag=false info="" end sub public property let SetFlag(byval v) flag=v end property public property get GFlag() GFlag=flag end property public property let SetMsg(byval m) info=m end property public property get GMsg() GMsg=info end property '得到邮箱服务器设置 private function getEmailset() set f1=new DbConstrol OpenConn() f1.DConn=conn set rs=f1.GetRs("select * from tbSetMail") getEmailset=rs.getrows rs.close set rs=nothing closeconn set f1=nothing end function public function Sends() call postFormFrom() fromname=getFormStr("fromname") fromaddress=getFormStr("fromaddress") toname=getFormStr("toname") toaddress=getFormStr("toaddress") title=getFormStr("title") content=getFormStr("content") isimportance=getFormStr("isimportance") if len(fromname)=0 then Msg "请填写发件人姓名!",0,"" response.End() end if if len(fromaddress)=0 then Msg "请填写发件人地址!",0,"" response.End() end if if len(toname)=0 then Msg "请填写收件人姓名!",0,"" response.End() end if if len(toaddress)=0 then Msg "请填写收件人地址!",0,"" response.End() end if if len(title)=0 then Msg "请填写邮件主题!",0,"" response.End() end if if len(content)=0 then Msg "请填写邮件内容!",0,"" response.End() end if if isimportance="1" then isimportance=1 else isimportance=3 end if arr=getEmailset() MailServerUser=trim(arr(4,0)) MailServerPass=trim(arr(5,0)) MailDomain=trim(arr(1,0)) MailServer=trim(arr(1,0)) call SendMail(toaddress,toname,title,content,fromaddress,fromname,MailServerUser,MailServerPass,MailDomain,MailServer,isimportance) if GFlag=true then call Msg(GMsg,0,"") response.End() else call Msg("邮件发送成功!",1,"SendMail.asp") end if end function '************************************************** '函数名:SendMail '作 用:用Jmail组件发送邮件 '参 数:MailtoAddress -----收信人信箱 ' MailtoName -----收信人姓名 ' Subject -----主题 ' MailBody -----信件内容 ' MailFrom -----发信人信箱 ' FromName -----发信人姓名 ' MailServerUser -----登陆邮箱用户名 ' MailServerPass -----登陆邮箱密码 ' MailDomain -----邮箱域名 'smtp服务器地址 ' MailServer -----发件SMTP服务器 'isimportance-----发送优先级 '************************************************** private Function SendMail(MailtoAddress,MailtoName,Subject,MailBody,MailFrom,FromName,MailServerUser,MailServerPass,MailDomain,MailServer,isimportance) ' on error resume next Dim JMail,JMailstat Set JMail=Server.CreateObject("JMail.Message") if err then err.clear 'Response.Write "组件检测失败" SetFlag=true SetMsg="组件检测失败" JMail.close() Set JMail=nothing exit function end if JMail.Charset="gb2312" '邮件字符集 设置标题和内容编码,如果标题有中文,必须设定编码为gb2312 ' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True JMail.silent=True '忽略错误 如果JMail.silent设置为true,ErrorCode包含的是错误代码 JMail.ContentType = "text/html" '邮件编码 如果发内嵌附件一定要注释掉这行,重要 JMail.AddRecipient MailtoAddress,MailtoName '收件人地址 JMail.ReturnReceipt = True '是否收条(验证中) JMail.From = MailFrom '发件人邮箱 JMail.MailDomain=MailDomain '邮箱所在域名(验证中) JMail.FromName = FromName '发件人姓名 JMail.MailServerUserName=MailServerUser '邮箱用户名 JMail.MailServerPassWord=MailServerPass '邮箱密码 JMail.Subject=Subject '邮件主题 JMail.Body=MailBody '邮件正文(纯文本格式) 'JMail.HMTLBody=MailBody '邮件正文(HTML格式) 'JMail.Priority=1 '邮件等级,1为加急,3为普通,5为低级 JMail.Priority=isimportance '邮件等级,1为加急,3为普通,5为低级 JMail.AddHeader "Originating-IP",Request.ServerVariables("REMOTE_ADDR") JMailstat=JMail.Send(MailServer) If JMailstat then 'response.write "成功" SetFlag=false SetMsg="发送成功!" else 'response.write "失败" SetFlag=true SetMsg="发送失败!" end if JMail.close() Set JMail=nothing End Function end class %> 相关文章: asp一些支付接口 Javascript中最常用的55个经典技巧 让Div浮动层浮在Flash上面下去 一个用JS操作Cookie的类 关于 var YAHOO = window.YAHOO || {}; 的解释 partial class ClientBuildManager类的编译功能 SQL精华 C#的四个基本技巧 40种网站设计常用技巧 对初学者的建议:ASP.NET技术的学习顺序 跨网页公布(Cross-Page Posting) 几种常用排序算法 几种常用的算法 asp缓存类 [笔记] php常见简单功能及函数 【技术性】Search知识 AWS实战 - 利用IAM对S3做访问控制 CentOS学习笔记 - 12. Nginx搭建Centos7.5远程repo DOM的那些事 idea + plantuml 画流程图 Javascript基础之Array数组API Mac 鼠须管 Rime 输入法 安装五笔输入法 教程 Python_网络编程 Rancher如何对接Ceph-RBD块存储 react 代码优化(一) ——事件处理 React-Native - 收藏集 - 掘金 spring cloud gateway 源码解析(4)跨域问题处理 tab.js分享及浏览器兼容性问题汇总 webpack4 一点通 Yeoman_Bower_Grunt 第三十一到第三十三天:我是精明的小卖家(一) 高度不固定时垂直居中 给github项目添加CI badge 开源SQL-on-Hadoop系统一览 理解IaaS, PaaS, SaaS等云模型 (Cloud Models) 前端攻城师 微服务入门【系列视频课程】 写给高年级小学生看的《Bash 指南》 一个6年java程序员的工作感悟,写给还在迷茫的你 Spring Batch JSON 支持 支付宝花15年解决的这个问题,顶得上做出十个支付宝 ... "无招胜有招"nbsp;史上最全的互… (13)Latex:基于ΤΕΧ的自动排版系统——写论文必备 (windows2012共享文件夹和防火墙设置 (ZT)薛涌:谈贫说富 (办公)springboot配置aop处理请求. (二)pulsar安装在独立的docker中,python测试 (附源码)spring boot基于Java的电影院售票与管理系统毕业设计 011449 (附源码)计算机毕业设计SSM智慧停车系统 (四)Linux Shell编程——输入输出重定向 (算法)前K大的和 .NET Core 版本不支持的问题 .net core 实现redis分片_基于 Redis 的分布式任务调度框架 earth-frost .NET Core引入性能分析引导优化
<!--#include file="conn.asp" --> <!--#include file="Fun.asp" --> <% '发送邮件类 class SendEmails '发送 private flag private info public sub Class_Initialize() flag=false info="" end sub public sub Class_Terminate() flag=false info="" end sub public property let SetFlag(byval v) flag=v end property public property get GFlag() GFlag=flag end property public property let SetMsg(byval m) info=m end property public property get GMsg() GMsg=info end property '得到邮箱服务器设置 private function getEmailset() set f1=new DbConstrol OpenConn() f1.DConn=conn set rs=f1.GetRs("select * from tbSetMail") getEmailset=rs.getrows rs.close set rs=nothing closeconn set f1=nothing end function public function Sends() call postFormFrom() fromname=getFormStr("fromname") fromaddress=getFormStr("fromaddress") toname=getFormStr("toname") toaddress=getFormStr("toaddress") title=getFormStr("title") content=getFormStr("content") isimportance=getFormStr("isimportance") if len(fromname)=0 then Msg "请填写发件人姓名!",0,"" response.End() end if if len(fromaddress)=0 then Msg "请填写发件人地址!",0,"" response.End() end if if len(toname)=0 then Msg "请填写收件人姓名!",0,"" response.End() end if if len(toaddress)=0 then Msg "请填写收件人地址!",0,"" response.End() end if if len(title)=0 then Msg "请填写邮件主题!",0,"" response.End() end if if len(content)=0 then Msg "请填写邮件内容!",0,"" response.End() end if if isimportance="1" then isimportance=1 else isimportance=3 end if arr=getEmailset() MailServerUser=trim(arr(4,0)) MailServerPass=trim(arr(5,0)) MailDomain=trim(arr(1,0)) MailServer=trim(arr(1,0)) call SendMail(toaddress,toname,title,content,fromaddress,fromname,MailServerUser,MailServerPass,MailDomain,MailServer,isimportance) if GFlag=true then call Msg(GMsg,0,"") response.End() else call Msg("邮件发送成功!",1,"SendMail.asp") end if end function '************************************************** '函数名:SendMail '作 用:用Jmail组件发送邮件 '参 数:MailtoAddress -----收信人信箱 ' MailtoName -----收信人姓名 ' Subject -----主题 ' MailBody -----信件内容 ' MailFrom -----发信人信箱 ' FromName -----发信人姓名 ' MailServerUser -----登陆邮箱用户名 ' MailServerPass -----登陆邮箱密码 ' MailDomain -----邮箱域名 'smtp服务器地址 ' MailServer -----发件SMTP服务器 'isimportance-----发送优先级 '************************************************** private Function SendMail(MailtoAddress,MailtoName,Subject,MailBody,MailFrom,FromName,MailServerUser,MailServerPass,MailDomain,MailServer,isimportance) ' on error resume next Dim JMail,JMailstat Set JMail=Server.CreateObject("JMail.Message") if err then err.clear 'Response.Write "组件检测失败" SetFlag=true SetMsg="组件检测失败" JMail.close() Set JMail=nothing exit function end if JMail.Charset="gb2312" '邮件字符集 设置标题和内容编码,如果标题有中文,必须设定编码为gb2312 ' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True JMail.silent=True '忽略错误 如果JMail.silent设置为true,ErrorCode包含的是错误代码 JMail.ContentType = "text/html" '邮件编码 如果发内嵌附件一定要注释掉这行,重要 JMail.AddRecipient MailtoAddress,MailtoName '收件人地址 JMail.ReturnReceipt = True '是否收条(验证中) JMail.From = MailFrom '发件人邮箱 JMail.MailDomain=MailDomain '邮箱所在域名(验证中) JMail.FromName = FromName '发件人姓名 JMail.MailServerUserName=MailServerUser '邮箱用户名 JMail.MailServerPassWord=MailServerPass '邮箱密码 JMail.Subject=Subject '邮件主题 JMail.Body=MailBody '邮件正文(纯文本格式) 'JMail.HMTLBody=MailBody '邮件正文(HTML格式) 'JMail.Priority=1 '邮件等级,1为加急,3为普通,5为低级 JMail.Priority=isimportance '邮件等级,1为加急,3为普通,5为低级 JMail.AddHeader "Originating-IP",Request.ServerVariables("REMOTE_ADDR") JMailstat=JMail.Send(MailServer) If JMailstat then 'response.write "成功" SetFlag=false SetMsg="发送成功!" else 'response.write "失败" SetFlag=true SetMsg="发送失败!" end if JMail.close() Set JMail=nothing End Function end class %>