?
sina的smtp驗證太厲害了,不管怎么樣傳數據都說驗證失敗,去www.
126
.com申請一個50MB的郵箱,報告“無效的user”,于是把msg.From也改成tindy@
126
.com,奇跡發生了,郵件發出去了,也!!!代碼如下:
Set
?msg?
=
?Server.CreateObject(
"
JMail.Message
"
)
msg.silent?
=
?
true
msg.Logging?
=
?
true
msg.Charset?
=
?
"
gb2312
"
msg.MailServerUserName?
=
?
"
tindy@126.com
"
?
msg.MailServerPassWord?
=
?
"
我的郵箱密碼
"
msg.AddHeader?
"
Originating-IP
"
,?Request.ServerVariables(
"
REMOTE_ADDR
"
)
msg.From?
=
?
"
tindy@126.com
"
?
'
?就是這個家伙,不能隨便寫的,一定要填你在126.com上申請的郵箱,很納悶
msg.FromName?
=
?Request.Form(
"
Name
"
)

msg.AddRecipient?
"
tindy@sina.com
"
msg.Subject?
=
?
"
test
"
body
=
request.form(
"
Content
"
)
msg.Body?
=
?body?

if
?
not
?msg.Send?(
"
smtp.126.com
"
)?
then
?
Response.write?
"
<pre>
"
?
&
?msg.log?
&
?
"
</pre>
"
?
else
?
set
?msg?
=
?
nothing
?
Response.Write?
"
郵件已發送!
"
?
end
?
if
'
========================================
已知問題是,對于sina的smtp驗證,同樣的方法,卻無法通過,一直納悶中,希望高手能夠幫我解決,因為俺可不想每個月登陸126.com的郵箱,沒空呀。
首先是jmail.smtpmail的核心代碼:
<
%
??
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????
'
關閉郵件對象
%
>
w3 Jmail4.3組件重新設計了其內部結構——使用Message對象代替原來的單一對象Jmail.smtpmail發送郵件,有些方法需要身份驗證的(如163、yahoo等),可以用下面的方法解決:
<
%
?????
Set
?jmail?
=
?Server.CreateObject(
"
JMAIL.Message
"
)???
'
建立發送郵件的對象
?????jmail.silent?
=
?
true
????
'
屏蔽例外錯誤,返回FALSE跟TRUE兩值j
????? jmail.logging?
=
?
true
???
'
啟用郵件日志
?????jmail.Charset?
=
?
"
GB2312
"
?????
'
郵件的文字編碼為國標
?????jmail.ContentType?
=
?
"
text/html
"
????
'
郵件的格式為HTML格式
?????jmail.AddRecipient?Email?????
'
郵件收件人的地址
?????jmail.From?
=
?
"
Email?From?for?Sender
"
???
'
發件人的E-MAIL地址
?????jmail.MailServerUserName?
=
?
"
UserName?of?Email
"
?????
'
登錄郵件服務器所需的用戶名
?????jmail.MailServerPassword?
=
?
"
Password?of?Email
"
?????
'
登錄郵件服務器所需的密碼
?????jmail.Subject?
=
?
"
Mail?Subject
"
????
'
郵件的標題?
????? jmail.Body?
=
?
"
Mail?Body
"
??????
'
郵件的內容
?????jmail.Prority?
=
?
1
??????
'
郵件的緊急程序,1?為最快,5?為最慢,?3?為默認值
?????jmail.Send(
"
Server?Address
"
)?????
'
執行郵件發送(通過郵件服務器地址)
?????jmail.Close()???
'
關閉對象
%
>
微軟自帶的CDONTS組件的發信的方法:
<
%
????
Set
?cdomail?
=
?Server.CreateObject(
"
CDONTS.NewMail
"
)??
'
建立郵件對象
????cdomail.Subject?
=
?
"
Mail?Subject
"
???
'
郵件標題
????cdomail.From?
=
?
"
Sender's?Mail
"
???
'
發件人的地址
????cdomail.To?
=
?
"
Email?will?from
"
???
'
收件人的地址
????cdomail.Body?
=
?
"
Mail?Body
"
???
'
郵件的內容
????cdomail.Send????
'
執行發送
%
>
代碼模塊化:
<
%
??
'
參數說明
??
'
Subject?????:?郵件標題
??
'
MailAddress?:?發件服務器的地址,如smtp.163.com
??
'
Email???????:?收件人郵件地址
??
'
Sender??????:?發件人姓名
??
'
Content?????:?郵件內容
??
'
Fromer??????:?發件人的郵件地址
??
Sub
?SendAction(subject,?mailaddress,?email,?sender,?content,?fromer)?
??????
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?
=
?mailaddress???
'
發送郵件的服務器
??????jmail.AddRecipient?Email????
'
郵件的收件人
??????jmail.SenderName?
=
?sender???
'
郵件發送者的姓名
??????jmail.Sender?
=
?fromer????
'
郵件發送者的郵件地址
??????jmail.Priority?
=
?
1
???
'
郵件的緊急程序,1?為最快,5?為最慢,?3?為默認值
??????jmail.Subject?
=
?subject??
'
郵件的標題
??????jmail.Body?
=
?content???
'
郵件的內容
??????
'
由于沒有用到密抄跟抄送,這里屏蔽掉這兩句,如果您有需要的話,可以在這里恢復
??????
'
jmail.AddRecipientBCC?Email???'密件收件人的地址
??????
'
jmail.AddRecipientCC?Email???'郵件抄送者的地址
??????jmail.Execute()???
'
執行郵件發送
??????jmail.Close????
'
關閉郵件對象
??
End?Sub
??
??
'
調用此Sub的例子
??
Dim
?strSubject,strEmail,strMailAdress,strSender,strContent,strFromer
??strSubject?????
=
?
"
這是一封用JMAIL發送的測試郵件
"
??strContent?????
=
?
"
JMail組件發送測試成功!
"
??strEmail???????
=
?
"
runbing@eyou.com
"
??strFromer??????
=
?
"
runbing@eyou.com
"
??strMailAddress?
=
?
"
mail.ubbcn.com
"
??
Call
?SendAction?(strSubject,strMailaddress,strEmail,strSender,strContent,strFromer)

%
>
Source: http://www.blueidea.com/tech/program/2003/721.asp
?
<
?%?
?
Set
??jmail??
=
??Server.CreateObject(?
"
?JMAIL.Message?
"
?)?
'
?建立發送郵件的對象??
'
?response.Write(sendFrom&"-"&sendTO&"-"&smtpserver&"-"&sendusername&"-"&sendpassword&"-"&subject&"-"&message&"-"&SendName)??
?jmail.silent??
=
???
false
???
'
?屏蔽例外錯誤,返回FALSE跟TRUE兩值??
?jmail.logging??
=
???
false
???
'
?啟用郵件日志??
?jmail.Charset??
=
???
"
?GB2312?
"
???
'
?郵件的文字編碼為國標??
?jmail.ContentType??
=
???
"
?text/html?
"
???
'
?郵件的格式為HTML格式??
?jmail.AddRecipient??
"
?gaingame@163.com?
"
???
'
?郵件收件人的地址??
?jmail.From??
=
???
"
?gaingame@163.com?
"
???
'
?發件人的E-MAIL地址??
?jmail.FromName??
=
???
"
?gaingame?
"
???
'
?發件人的名字??
?jmail.MailServerUserName??
=
???
"
?gaingame?
"
???
'
?登錄郵件服務器所需的用戶名??
?jmail.MailServerPassword??
=
???
"
?gaingame?
"
???
'
?登錄郵件服務器所需的密碼??
?jmail.Subject??
=
???
"
?fine?to?see?you?friend?
"
???
'
?郵件的標題??
?jmail.Body?
=
?
"
?ddd?
"
???
'
?郵件的內容??
'
?jmail.Prority?=1?'郵件的緊急程序,1?為最快,5?為最慢,?3?為默認值?(我使用的是w3jmail4不知道為什么不注釋此項就是發送不成功)?
'
?jmail.Send("smtp.163.com")?'執行郵件發送(通過郵件服務器地址)??
?
if
?(?
not
??jmail.Send?(?
"
?smtp.163.com?
"
?))??
then
???
'
?發送并判斷發送是否成功?
?SendMail?
=
?
"
?<center>Fail?to?send?the?Email?2!</center>?
"
??
?
else
??
SendMail?
=
?
"
?<center>Success!</center>?
"
??
?
end
???
if
??
response.Write(sendmail)?
jmail.Close()??
'
?關閉對象?
?%?
>
Source:
http://blog.csdn.net/kepeizong/archive/2006/05/18/744908.aspx
posted on 2007-03-10 17:21
百年 閱讀(1015)
評論(5) 編輯 收藏 所屬分類:
Asp Article