asp中jmail邮件无法发送,请哪位大神解答一下,谢谢。

asp中jmail邮件无法发送,请哪位大神解答一下,谢谢。,第1张

很多时候用JMail发送邮件一直出错,常见原因有:

1。发送邮件服务器地址写错。如果用 163邮箱来发送,服务器地址应当写成 smtp.163.com

2。很多发送邮件服务器需要验证邮箱登录名(例:laifangsong@163.com)和密码(123456),如果这两样没提交,发送也会失败。

3。发件人邮箱地址和发送邮件服务器登录名不统一。

还有最重要的,,组件有安装吗???

请参考以下说明:

首先服务器上要安装发送邮件的组件,如JMAIL

然后编写代码

<%

Email = " test@163.com " ''收件人Email

Set jmail = Server.CreateObject("JMAIL.Message")'建立发送邮件的对象

jmail.silent = false '屏蔽例外错误,返回FALSE跟TRUE两值

jmail.logging = true '启用邮件日志

jmail.Charset = "GB2312" '邮件的文字编码为国标

jmail.ContentType = "text/html" '邮件的格式为HTML格式

jmail.AddRecipient Email '邮件收件人的地址

jmail.From = " test@163.com " '发件人的E-MAIL地址

jmail.MailServerUserName = " test@163.com " '登录邮件服务器所需的用户名

jmail.MailServerPassword = "test" '登录邮件服务器所需的密码

jmail.Subject = "Jmail邮件" '邮件的标题

jmail.Body = "Jmail邮件测试" '邮件的内容

jmail.Priority = 1'邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值

jmail.Send("mail.163.com") '执行邮件发送(通过邮件服务器地址)。请修改成你的邮件服务器SMTP地址

jmail.Close() '关闭对象

%>

下面的是2个页面,我成功测试过。

mess.thml页面:

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>..::驶向天边-网页设计-::.. jmail提交邮箱代码测试</title>

<link rel="stylesheet" type="text/css" href="http://www.at63.com/images/css.css">

<style type="text/css">

<!--

body,td,th {

font-size: 12px

color: #20707d

line-height:22px

font-family:Verdana, Arial, Helvetica, sans-serif

}

body {

margin-left: 0px

margin-top: 0px

margin-right: 0px

margin-bottom: 0px

background:url(image/bg.jpg)

background-position:center

}

*{ margin:0padding:0border:0}

html,body { height:100%}

a:link {

color: #20707d

text-decoration:none

}

a:visited {

color: #20707d

text-decoration:none

}

a:hover {

color: #2F99D2

text-decoration:none

}

a:active {

color: #20707d

text-decoration:none

}

.top{margin:0 autowidth:800pxbackground:#FFFFFFheight:100%}

.logo{margin:0px 5px 0px 5pxbackground: url(image/MAIN_04.gif) repeat-xheight:87pxwidth:790}

.logoleft{float:leftheight:87px}

.logoright{float:righttext-align:rightpadding-right:10px}

.searchinput{border:medium nonebackground-color:transparentfont-family:Verdana, Arial, Helvetica, sans-serifwidth:152pxheight:27pxfont-size:14pxline-height:28pxcolor:#20707d}

.pagediv{margin:0px 5px 0px 5pxheight:100%}

.pagemenu{ width:227pxheight:100%float:leftheight:100%}

.pagemenu0{ float:leftwidth:7px}

.pagemenu1{float:leftwidth:556pxbackground-color:#FFFFFF}

.menuleft{padding-left:30px}

.foot{height:30pxbackground:#20707dwidth:790pxmargin:0px 5px 0px 5pxcolor: #EEFBFFtext-align: right}

.footdiv{height:30pxbackground:#fffwidth:790px}

.content{width:530pxpadding:0px 10px 0px 10pxtext-align: left}

.title{width:530pxpadding:10px 10px 0px 10pxtext-align:rightfont-family:Arial, Helvetica, sans-serif}

.gcimg{float:leftwidth:33%text-align:centerheight:120pxoverflow:hiddenmargin:0 auto}

.input3{border:1px #CCCCCC solidfont-family: Verdana, Arial, Helvetica, sans-serif}

.button{border:1px #CCCCCC solidfont-size:12pxbackground: #E8F4F4color: #006666font-family:Verdana, Arial, Helvetica, sans-serifheight:20pxline-height:20px}

.ListTitle{border-bottom:1px #5FA5D8 dashed}

.left{padding-left:10px}

.gctxt{float:leftwidth:33%text-align:centermargin:0 auto}

.subbg{ background:url(image/MAIN_25.gif) no-repeat centerheight:191pxwidth:556px}

-->

</style>

</head>

<body>

<script language="JavaScript" type="text/javascript">

function isEmail(vEMail)

{

var regInvalid=/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/

var regValid=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/

return (!regInvalid.test(vEMail)&&regValid.test(vEMail))

}

function check()

{

if ((document.form1.sendemail.value)=="")

{

window.alert ("请输入发件邮箱!")

document.form1.sendemail.select()

document.form1.sendemail.focus()

return false

}

if ((document.form1.title.value)=="")

{

window.alert ("请输入相关主题!")

document.form1.title.select()

document.form1.title.focus()

return false

}

if ((document.form1.conten.value)=="")

{

window.alert ("请输入相关描述!")

document.form1.conten.select()

document.form1.conten.focus()

return false

}

if ((document.form1.name.value)=="")

{

window.alert ("请输入联系人!")

document.form1.name.select()

document.form1.name.focus()

return false

}

if ((document.form1.tel.value)=="")

{

window.alert ("请输入联系电话!")

document.form1.tel.select()

document.form1.tel.focus()

return false

}

if (!(isEmail(document.form1.email.value )))

{

alert("输入的邮箱地址错误,请重新输入!")

document.form1.email.select()

document.form1.email.focus()

return false

}

else

{ document.form1.tHtml.value=document.form1.innerHTML

document.form1.submit()}

}

</script>

<form id="form1" name="form1" method="post" action="jmail.asp">

<table width="350" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">

<tr>

<td colspan="2"><font color="#008F9A"><strong>给我们留言</strong></font></td>

</tr>

<tr>

<td height="20" align="left" >发送邮箱:</td>

<td><input name="sendemail" type="text" class="input3" id="sendemail" size="20" />

*</td>

</tr>

<tr>

<td width="65" height="20" align="left" >相关主题:</td>

<td><input name="title" type="text" class="input3" id="title" size="20" />

*

<input name="subject" type="hidden" id="subject" value="客户反馈信息" />

<input name="tHtml" type="hidden" id="tHtml" /></td>

</tr>

<tr>

<td width="65" height="80" align="left" >相关描述:</td>

<td><textarea name="conten" cols="30" rows="5" class="input3" id="conten"></textarea>

*</td>

</tr>

<tr>

<td width="65" height="20" align="left" >公司名称:</td>

<td><input name="comname" type="text" class="input3" id="comname" size="20" /></td>

</tr>

<tr>

<td width="65" height="20" align="left" >联 系 人:</td>

<td><input name="name" type="text" class="input3" id="name" size="20" />

*</td>

</tr>

<tr>

<td width="65" height="20" align="left" >联系电话:</td>

<td><input name="tel" type="text" class="input3" id="tel" size="20" />

*务必真实</td>

</tr>

<tr>

<td width="65" height="20" align="left" >联系地址:</td>

<td><input name="add" type="text" class="input3" id="add" size="20" /> </td>

</tr>

<tr>

<td width="65" height="20" align="left" >电子邮件:</td>

<td><input name="email" type="text" class="input3" id="email" size="20" />

*务必真实</td>

</tr>

<tr>

<td height="20"> </td>

<td>

<input name="Submit3" type="button" class="button" value="提交" onclick="return check()"/>

  

<input name="Submit4" type="reset" class="button" value="重置" /> </td>

</tr>

<tr>

<td> </td>

<td> </td>

</tr>

</table>

</form></body>

</html>

jmail.asp页面:

<%

dim sendemail,jmail,tHtml,Subject,content,at63

Subject=trim(request.form("Subject"))

tHtml=trim(request.form("tHtml"))

sendemail=trim(request.form("sendemail"))

Set JMail = Server.CreateObject("Jmail.Message")

JMail.From = "daigua2102@163.com"

'来自哪果发送

JMail.FromName = "客户反馈"

'发送名

JMail.CharSet = "GB2312"

JMail.Priority = 3

JMail.ReplyTo = "daigua2102@163.com"

'回复email

JMail.AddRecipient sendemail

JMail.Subject = Subject

JMail.AppendText "客户反馈"

content = "<link rel=""stylesheet"" type=""text/css"" href=""http://www.at63.com/send/css.css"">"

content=content &thtml

'thtml变量是整个表单的html代码,表单设置的文本字段<input name="sendemail" type="text" class="input3" id="sendemail" size="20" />,提交时用innerHTML获取表单html代码

JMail.AppendHTML content

JMail.MailServerusername = "daigua2102@163.com"

'服务邮箱地址

JMail.MailServerPassword = "4722188"

'服务邮箱密码.邮箱密码是正确的.用来演试的.请不要修改我的修改,谢谢合作

if (JMail.Send ("smtp.163.com")) then

'JMail.Send 发送服务器

response.write "<script>alert('发送成功!')history.back(-1)</script>"

else

response.write "<script>alert('企业邮箱服务器出现问题.发送失败!')history.back(-1)</script>"

end if

%>


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/46404.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-02-24
下一篇2023-02-24

发表评论

登录后才能评论

评论列表(0条)

    保存