<%
if Request("MailtoAddress") <> "" then
msg = SendMail
(Request("SMTPServer"),Request("SMTPServerUserName"),Request("SMTPServerPassword"),
Request("MailDomain"),Request("MailtoAddress"),Request("MailtoName"),Request("Subject"),
Request("MailBody"),Request("FromName"),Request("MailFrom"),Request("Priority"))
if msg then Response.Write("發(fā)送成功") else Response.Write("發(fā)送不成功")
Response.End()
end if
function
SendMail(SMTPServer,SMTPServerUserName,SMTPServerPassword,MailDomain,MailtoAddress,MailtoName,
Subject,MailBody,FromName,MailFrom,Priority)
dim JMail, msg
set JMail=Server.CreateObject("JMail.Message")
JMail.Charset="gb2312" '編碼
JMail.silent=true '設置為true,JMail不會拋出例外錯誤.
JMail.ContentType = "text/plain" '郵件正文格式
'JMail.ServerAddress = SMTPServer '用來發(fā)送郵件的SMTP服務器(無效)
'指定郵件服務器的地址。可以指定多個服務器,用分號點開。可以指定端口號。
'如果serverAddress保持空白,JMail會嘗試解決遠程郵件服務器,然后直接發(fā)送到服務器上去。???
'如:JMail.ServerAddress = &tquo;mail.mydom.net; mail2.mydom.net:2500"
JMail.MailServerUserName = SMTPServerUserName '登錄用戶名
JMail.MailServerPassWord = SMTPServerPassword '登錄密碼
JMail.MailDomain = MailDomain '域名(如果用“name@domain.com”這樣的用戶名登錄時,請指明domain.com
JMail.AddRecipient MailtoAddress,MailtoName '收信人
JMail.Subject = Subject '主題
JMail.Body = MailBody '郵件正文(純文本格式)
JMail.FromName = FromName '發(fā)信人姓名
JMail.From = MailFrom '發(fā)信人Email
JMail.Priority = Priority '郵件等級12345
msg = JMail.Send(SMTPServer)
JMail.Close
set JMail = nothing
SendMail = msg
end function
%>