<%
Set jmail = Server.CreateObject("JMAIL.SMTPMail") '创建一个JMAIL对象
jmail.silent = true 'JMAIL不会抛出例外错误,返回的值为FALSE跟TRUE
jmail.logging = true '启用使用日志
jmail.Charset = "GB2312" '邮件文字的代码为简体中文
jmail.ContentType = "text/html" '邮件的格式为HTML的
jmail.ServerAddress = "Server Address" '发送邮件的服务器
jmail.AddRecipient Email'邮件的收件人
jmail.SenderName = "SenderName"'邮件发送者的姓名
jmail.Sender = "Email Address"'邮件发送者的邮件地址
jmail.Priority = 1 '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值
jmail.Subject = "Mail Subject" '邮件的标题
jmail.Body = "Mail Body" '邮件的内容
jmail.AddRecipientBCC Email '密件收件人的地址
jmail.AddRecipientCC Email '邮件抄送者的地址
jmail.Execute() '执行邮件发送
jmail.Close'关闭邮件对象
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>表单提交至邮箱(非Mailto,不弹出Outlook)</title>
</head>
<body>
<h4>表单提交至邮箱(非Mailto,不弹出Outlook)</h4>
如发送失败请先检查程序常量设置,服务器是否安装了Jmail4.3以上版本。<br>
Jmail组件下载:http://www.skycn.com/soft/5555.html<br>
如果返回“The message was undeliverable. All servers failed to receive the message”说明服务器或服务器所在的网络有防火墙,不允许IIS进程发送邮件。
<form name="form1" method="post">
邮件标题:
<input type="text" name="tit" id="tit">
<br>
邮件正文(支持HTML):<br>
<textarea name="con" id="con" cols="45" rows="5"><b>Jmail发信测试,这是一封<font color="#FF0000">HTML邮件</font></b></textarea>
<input type="submit" name="button" id="button" value="提交">
</form>
<%
if request.Form<>"" then
Dim SendStat
SendStat = Jmail("hibaidu8@126.com",Trim(Request.Form("tit")),Trim(Request.Form("con")),"US-ASCII","text/plain")
Response.Write SendStat
end if
%>
<%
'--------------------------------------------------------------------
Function Jmail(mailTo,mailTopic,mailBody,mailCharset,mailContentType)
'****************************************************
'***************以下信息根据需要设置常量开始*****************
'****************************************************
Dim ConstFromNameCn,ConstFromNameEn,ConstFrom,ConstMailDomain,ConstMailServerUserName,ConstMailServerPassword
ConstFromNameCn = "Test"'发信人中文姓名(发中文邮件的时候使用),例如‘张三’
ConstFromNameEn = "Test"'发信人英文姓名(发英文邮件的时候使用),例如‘zhangsan’
ConstFrom = ""'发信人邮件地址,例如‘zhangsan@163.com’
ConstMailDomain = ""'smtp服务器地址,例如smtp.163.com
ConstMailServerUserName = ""'smtp服务器的信箱登陆名,例如‘zhangsan’。注意要与发信人邮件地址一致!
ConstMailServerPassword = ""'smtp服务器的信箱登陆密码
'***************根据需要设置常量结束*****************
'-----------------------------以下内容无需改动------------------------------
On Error Resume Next
Dim myJmail
Set myJmail = Server.CreateObject("JMail.Message")
myJmail.Logging = True'记录日志
myJmail.ISOEncodeHeaders = False'邮件头不使用ISO-8859-1编码
myJmail.ContentTransferEncoding = "base64"'邮件编码设为base64
myJmail.AddHeader "Priority","3"'添加邮件头,不要改动!
myJmail.AddHeader "MSMail-Priority","Normal"'添加邮件头,不要改动!
myJmail.AddHeader "Mailer","Microsoft Outlook Express 6.00.2800.1437"'添加邮件头,不要改动!
myJmail.AddHeader "MimeOLE","Produced By Microsoft MimeOLE V6.00.2800.1441"'添加邮件头,不要改动!
myJmail.Charset = mailCharset
myJmail.ContentType = mailContentType
If UCase(mailCharset) = "GB2312" Then
myJmail.FromName = ConstFromNameCn
Else
myJmail.FromName = ConstFromNameEn
End If
myJmail.From = ConstFrom
myJmail.Subject = mailTopic
myJmail.Body = ConstMailServerPassword
myJmail.AddRecipient mailTo
myJmail.MailDomain = ConstMailDomain
myJmail.MailServerUserName = ConstMailServerUserName
myJmail.MailServerPassword = ConstMailServerPassword
myJmail.Send ConstMailDomain
myJmail.Close
Set myJmail=nothing
If Err Then
Jmail=Err.Description
Err.Clear
Else
Jmail="OK"
End If
On Error Goto 0
End Function
'--------------------------------------------------------------------
%>
</body>
</html>
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)