关于ASP发送邮件的问题
这个程序是可以运行的, 我用的是我自己的邮箱。
但一个邮箱后就用不了了(企业邮箱Smtp cname mail.hcpharm.com. 或 smtp.hcpharm.com)请问这是为什么呢?
<%
username=request.Form("username")
unitname=request.Form("unitname")
address=request.Form("address")
ecode=request.Form("ecode")
country = request.Form("country")
tel = request.Form("tel")
title = request.Form("title")
email = request.Form("email")
url = request.Form("url")
content = request.Form("content")
Set jmail = Server.CreateObject("JMAIL.Message")
jmail.silent = true
jmail.Charset = "GB2312"
jmail.ContentType = "text/html"
jmail.AddRecipient"leon83325@163.com"
jmail.From = "leon83325@163.com"
jmail.MailServerUserName = "leon83325@163.com"
jmail.MailServerPassword = "password"
jmail.Subject = "text"
mess = mess & "username:" & username & vbcrlf
mess = mess & "unitname:" & unitname & vbcrlf
mess = mess & "address:" & address & vbcrlf
mess = mess & "ecode:" & ecode & vbcrlf
mess = mess & "country:" & country & vbcrlf
mess = mess & "tel:" & tel & vbcrlf
mess = mess & "title:" & title & vbcrlf
mess = mess & "email:" & email & vbcrlf
mess = mess & "url:" & url & vbcrlf
mess = mess & "content:" & content & vbcrlf
JMail.Body = mess
JMail.Priority = 1
if JMail.Send( "smtp.163.com" ) then
response.Write("邮件发送成功")
else
response.Write("邮件发送失败")
end if
JMail.Close()
Set JMail = Nothing
%>
答案:用这段代码试试吧:
'下面是发送邮件
dim content
content="发送的邮件内容。"
Set objMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.163.com" '邮件服务器
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "**********@163.com"'用户名
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*********"'密码
objCDOSYSCon.Fields.Update
Set objMail.Configuration = objCDOSYSCon
''系统配置结束
objMail.From = "*********@163.com"''发送人
objMail.Subject = "邮件标题" ''标题
objMail.To = umail''收件人
objMail.HtmlBody = content
objMail.Send
Set objMail = Nothing
Set objCDOSYSCon = Nothing
response.write "<script>alert('发送成功!');</script>"
其他:发送邮件时要注意,不要发送得太快了。短时间内发送大量的邮件,会被ANTISPAM(垃圾邮件拒绝)。一般是加个时间控制器,每隔多少秒后再发送第二封。。。
上一个:asp上传大文件时,提示错误: Active Server Pages 错误 'ASP 0115' 意外错误
下一个:在ASP中表单中,我输入了10条成绩记录,然后点击提交的时候,我要怎么去接收每条成绩对应的学生半保存,