云主机上安装使用JMAIL问题集锦:
一、Jmail 问题集锦
1、JMAIL的版本是多少?
JMAIL 是免费的4.0版本
2、JMAIL 需要单独的发信服务器吗?
JMAIL 需要设置单独的发信服务器
如:set mail=server.CreateObject("jmail.SMTPMail")
mail.ServerAddress = "mail.domain.com"
3、为什么使用jmail发信时发信失败?
最可能的原因是你指定的发信服务器需要发信认证,而你在程序中没有指定发信用户名和密码,具体的编码为:
set mail=CreateObject("jmail.Message")
mail.Charset ="gb2312"
mail.From ="from@hichina.com"
mail.AddRecipient "to@hichina.com"
mail.MailDomain="mail.hichina.com"
mail.MailServerUserName = " from @hichina.com"
mail.MailServerPassWord = "****"
mail.subject=”test”
mail.body= “欢迎”
'On Error Resume Next
mail.Send("mail.hichina.com")
mail.close()
set mail=nothing
4、Jmail 能发送附件吗?
可以
mail.AddAttachment (replace(server.MapPath("/test.doc"),"",""))
5、 Jmail 可以发送Html格式的邮件吗?
可以,具体看使用手册。
6、Jmail组件实例。
(1)发信服务器需要认证。
'以下的代码是发信服务器需要认证的,例如我们的邮箱服务器
<%
set mail=CreateObject("jmail.Message")
mail.Charset ="gb2312"
mail.From ="test@hichina.com"
mail.AddRecipient "test@hichina.com"
mail.MailDomain="mx.hichina.com"
mail.MailServerUserName = "test@hichina.com"
mail.MailServerPassWord = "*****"
mail.subject=Subject
mail.body= "hi china.com"
On Error Resume Next
mail.Send("mx.hichina.com")
mail.close()
set mail=nothing
response.write "发送成功"
%>
<%
set mail=CreateObject("jmail.Message")
mail.Charset ="gb2312"
mail.From ="test@hichina.com"
mail.AddRecipient "test@hichina.com"
mail.MailDomain="mx.hichina.com"
mail.MailServerUserName = "test@hichina.com"
mail.MailServerPassWord = "*****"
mail.subject=Subject
mail.body= "hi china.com"
On Error Resume Next
mail.Send("mx.hichina.com")
mail.close()
set mail=nothing
response.write "发送成功"
%>
(2)发信服务器不需要认证。
'发信服务器不需要认证的
<%
set mail=server.CreateObject("jmail.SMTPMail")
mail.Charset="gb2312"
mail.ServerAddress = "mx.hichina.com"
mail.Sender="test@hichina.com"
mail.SenderName="test"
mail.AddRecipient("test@sina.com")
mail.Subject ="jmail邮件测试"
mail.body="jmail邮件测试."
mail.Priority="1"
'On Error Resume Next
mail.Execute()
mail.Close
Set mail=nothing
response.write "发送成功"
%>
<%
set mail=server.CreateObject("jmail.SMTPMail")
mail.Charset="gb2312"
mail.ServerAddress = "mx.hichina.com"
mail.Sender="test@hichina.com"
mail.SenderName="test"
mail.AddRecipient("test@sina.com")
mail.Subject ="jmail邮件测试"
mail.body="jmail邮件测试."
mail.Priority="1"
'On Error Resume Next
mail.Execute()
mail.Close
Set mail=nothing
response.write "发送成功"
%>
二、Winhttp Post问题集锦
1、用Winhttp Pos组件Post的内容服务器无法收到结果?
需要在程序中加入如下代码:
http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
具体例子为:
Err.Clear
On Error Resume Next
set http=server.CreateObject("WinHttp.WinHttpRequest.5.1")
http.SetTimeouts 30000,50000,30000,30000
http.Open "POST", "http://test.hichina.com/sms_gateway/sms_api", False
http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send(sendStr)
If Err.Number = 0 Then 'POST成功
SendPwd=trim(http.responsetext)
else
SendPwd=-1
end if
http.Abort()
2、Pos组件返回的结果是乱码?
由于中文编码问题,如果返回的结果中含有中文,需要进行编码
vIn=http.responseBody
strReturn = ""
For q = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,q,1))
If ThisCharCode