邮箱Post提交无效,有源码[已解决]
本帖最后由 AUFS 于 2011-4-15 12:29 编辑提交总是出错,老大帮忙看看...是不是要写Cookies才可以正常发送.小弟研究了很久无果...发上论坛上望达人可以帮帮忙看看#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <WinHttp_GetRespond.au3>
#include <array.au3>
Opt('GUIDataSeparatorChar','!')
Dim $rContext,$QQNum,$UUI,$Tie
Global $SendName,$SendID,$UrlSid,$QQNum,$SenQNum,$CodeY
Dim $TxSendTxt,$Sid,$HeaderUrl
$Form2 = GUICreate("邮件发送测试", 337, 439, 341, 157)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 8, 43, 17)
$Input1 = GUICtrlCreateInput("", 64, 5, 121, 21)
$Label2 = GUICtrlCreateLabel("密 码:", 24, 35, 43, 17)
$Input2 = GUICtrlCreateInput("", 64, 32, 121, 21,$ES_PASSWORD)
$Pic1 = GUICtrlCreatePic("", 192, 23, 130, 53)
$Label3 = GUICtrlCreateLabel("验证码:", 16, 59, 43, 17)
$Input3 = GUICtrlCreateInput("", 64, 56, 121, 21)
$Label4 = GUICtrlCreateLabel("点击图片换下一张..", 200, 0, 106, 17)
$Group1 = GUICtrlCreateGroup("", 3, 184, 329, 249)
$Label5 = GUICtrlCreateLabel("标题:", 16, 200, 31, 17)
$Input4 = GUICtrlCreateInput("标题", 48, 198, 265, 21)
$Label6 = GUICtrlCreateLabel("内容:", 16, 232, 31, 17)
$Edit1 = GUICtrlCreateEdit("内容", 16, 248, 305, 145)
;GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("登录", 72, 85, 147, 33)
$Button2 = GUICtrlCreateButton("提交", 128, 400, 75, 25)
$Radio1 = GUICtrlCreateRadio("选择", 8, 128, 57, 17)
GUICtrlSetState(-1,$GUI_CHECKED)
$Radio2 = GUICtrlCreateRadio("填写收件人", 8, 159, 89, 17)
$Combo1 = GUICtrlCreateCombo("", 64, 128, 265, 25,BitOR($CBS_DROPDOWN,$WS_VSCROLL,$CBS_DROPDOWNLIST))
GUICtrlSetState(-1,$GUI_DISABLE)
$Input5 = GUICtrlCreateInput("", 96, 157, 233, 21)
GUICtrlSetState(-1,$GUI_DISABLE)
GUISetState(@SW_SHOW)
;Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
$MyOpen=_WinHttpOpen('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)')
$rContext=_WinHTTP_GetRespond($MyOpen,"https://mail.qq.com/cgi-bin/loginpage",4 + 2,50000,"")
_Get_Code()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
_WinHttpCloseHandle($MyOpen)
Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
Exit
Case $Pic1
_Get_Code()
Case $Combo1
GUICtrlSetData($Input5,GUICtrlRead($Combo1))
Case $Radio1
GUICtrlSetState($Input5,$GUI_DISABLE)
GUICtrlSetState($Combo1,$GUI_ENABLE)
Case $Radio2
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetState($Input5,$GUI_ENABLE)
Case $Button1
$NName = GUICtrlRead($Input1)
$NPwd = GUICtrlRead($Input2)
$NCode = GUICtrlRead($Input3)
_Loing($NName,$NPwd,$NCode)
Case $Button2
If GUICtrlRead($Combo1) <> '' And GUICtrlRead($Input4) <> '' And GUICtrlRead($Edit1) <> '' Then
$UUI = ''
$Tie = GUICtrlRead($Input4)
$Txt = GUICtrlRead($Edit1)
$SeN = GUICtrlRead($Combo1)
$CF = StringSplit($Txt,@LF)
For $i = $CF To 1 Step - 1
If $CF[$i] <> '' Then
$TE = '<DIV>' &StringRegExpReplace($CF[$i],'(\r)','') & '</DIV>' & @CRLF
$UUI = StringReplace($TE & $UUI,'<DIV></DIV>','<DIV> </DIV>')
EndIf
Next
$PCF = StringSplit(GUICtrlRead($Combo1),'?')
;MsgBox(64,'提示',$PCF & @CRLF & $PCF)
_SendTxt($SendName,$SendID,$UrlSid,$PCF,$PCF,$Tie,$UUI,'');;提交
EndIf
EndSwitch
WEnd
Func _Loing($Name,$PWD,$Code)
If $Name <> '' And $PWD <> '' And $Code <> '' Then
GUICtrlSetState($Button1,$GUI_DISABLE)
$Context = 'sid=%2C2%2Czh_CN&firstlogin=false&starttime=1302438026859&redirecturl=&f=html&p=' & $PWD & '&ept=0&delegate_url=&s=&ts=1302430206&from=&ppp=&chg=0&target=&checkisWebLogin=3&uin=' & $Name & '&aliastype=@qq.com&pp=00000000&verifycode='&$Code
$rContext=_WinHTTP_GetRespond($MyOpen,"https://mail.qq.com/cgi-bin/login?sid=,2,zh_CN",1 + 4 + 2,50000,$Context,'',"Content-Type: text/html; charset=gbk")
If @error Then MsgBox(0,@error,"出错了")
;MsgBox(64,'Cookies',$rContext)
;MsgBox(64,'编码类型',$rContext)
;MsgBox(64,'完整Header',$rContext)
;MsgBox(64,'数据内容',BinaryToString($rContext))
$HeaderUrl = StringRegExp(BinaryToString($rContext),'urlHead="(.+?)";', 3);;返回Header网址
$CookSid = StringRegExp(BinaryToString($rContext),'qm_sid=(.+?),', 3);;Cookiesqm_sid码
$RtSid = StringRegExp(BinaryToString($rContext),'sid=(.+?)";', 3);;返回本次会话的SID
If @error = 0 Then
;MsgBox(64,'提示','成功登录')
$QQNum = GUICtrlRead($Input1)
$QQIDUrl = $HeaderUrl & 'grouplist?t=compose_group&sid=' & $RtSid & '&newwin=true&nocheckframe=true'
$rContext=_WinHTTP_GetRespond($MyOpen,$QQIDUrl,4 + 2,50000,'','',"Content-Type: text/html; charset=UTF-8")
$UrlSid = $RtSid
If @error Then MsgBox(0,@error,"出错了")
;MsgBox(64,'Cookies',$rContext)
;MsgBox(64,'编码类型',$rContext)
;MsgBox(64,'完整Header',$rContext)
;MsgBox(64,'数据内容',BinaryToString($rContext))
$OkHtml = StringRegExpReplace(BinaryToString($rContext),'(\s)','');;返回网页源码并删除回车空格
$GuID1 = StringRegExp($OkHtml,'<optionid="Gname_(.+?)</option>', 3);;
;_ArrayDisplay($GuID1)
For $i = 0 To UBound($GuID1) - 1
$CFTx = StringSplit($GuID1[$i],'"')
If $CFTx <= 4 Then
;MsgBox(64,'提示',StringReplace($CFTx,'>','') & @CRLF & $CFTx)
$QQMaiID = StringReplace($CFTx,'>','') & '?' & $CFTx
GUICtrlSetData($Combo1,$QQMaiID,StringReplace($CFTx,'>','') & '?' & $CFTx)
EndIf
Next
GUICtrlSetState($Combo1,$GUI_ENABLE)
$NewUrl = $HeaderUrl & 'readtemplate?sid=' & $RtSid & '&t=compose&s=cnew&loc=frame_html,,,21';;转到写信页面取发送ID
$rContext=_WinHTTP_GetRespond($MyOpen,$NewUrl,4 + 2,50000)
If @error Then MsgBox(0,@error,"出错了")
;MsgBox(0,$rContext,$rContext)
$OkHtml = StringRegExpReplace(BinaryToString($rContext),'(\s)','');;返回网页源码并删除回车空格
;FileWriteLine('哈哈.txt',$OkY)
$SendIDK = StringRegExp($OkHtml,'"/><inputtype="hidden"name="(.+?)<inputtype="hidden"name="sid"value="', 3);;返回所需的发送ID号
$SIDCF = StringSplit($SendIDK,'"')
$SendName = $SIDCF;发送代码Name
$SendID = $SIDCF;发关代码ID
;MsgBox(64,'提示','发送代码Name:' & $SendName & @CRLF & '发送代码ID:' & $SendID)
Else
MsgBox(48,'提示','登录失败')
GUICtrlSetState($Button1,$GUI_ENABLE)
Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
_Get_Code()
GUICtrlSetData($Input3, "")
EndIf
EndIf
EndFunc
Func _SendTxt(ByRef $S1,ByRef $S2,ByRef $Sid,ByRef $GQName,ByRef $GQNum,ByRef $Tile,ByRef $SendTxt,$CodeY);;提交
GUICtrlSetState($Button2,$GUI_DISABLE)
If $S1 <> '' And $S2 <> '' And $Sid <> '' And $GQName <> '' And $GQNum <> '' And $Tile <> '' And $SendTxt <> '' Then
$TxSendTxt = '-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="sid"'&@CRLF&@CRLF& $Sid &@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="actiontype"'&@CRLF&@CRLF&'send'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="bigattachcnt"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="priority"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="contenttype"'&@CRLF&@CRLF&'html'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="savesendbox"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="sendname"'&@CRLF&@CRLF&'alias'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="qqshow"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="fmailid"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="cattachelist"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="fattachlist"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="rsturl"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="fileidlist"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="verifykey"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="verifycode"'&@CRLF&@CRLF& $CodeY &@CRLF& _;;验证码
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="verifycode_cn"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="t"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="s"'&@CRLF&@CRLF&'group'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="contenttext"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="hitaddrbook"'&@CRLF&@CRLF&'0'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="backurl"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="newwin"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="mailtype"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="sid"'&@CRLF&@CRLF& $Sid &@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="' & $S1 & '"'&@CRLF&@CRLF& $S2 &@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="groupname"'&@CRLF&@CRLF& $GQName &@CRLF& _;;Q名称
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="qqgroupid"'&@CRLF&@CRLF& $GQNum &@CRLF& _;;Q号码
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="subject"'&@CRLF&@CRLF& $Tile &@CRLF& _;;标题
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="votesubject"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="votetype"'&@CRLF&@CRLF&'secret'&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="option"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="option"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="option"'&@CRLF&@CRLF&@CRLF& _
'-----------------------------7db2802d1d023a'&@CRLF& _
'Content-Disposition: form-data; name="content__html"'&@CRLF&@CRLF& $SendTxt & _;;内容
'-----------------------------7db2802d1d023a--'&@CRLF
;'Referer: '& $HeaderUrl &'grouplist?t=compose_group&newwin=&sid=' & $Sid & @CRLF & _
$HeUrl1 = StringSplit($HeaderUrl,'/');;拆分网址
;_WinHttpQueryHeaders($MyOpen,'Host',$HeUrl)
$HeaderAdd = 'Accept-Language: zh-cn' & @CRLF & 'Content-Type: multipart/form-data; boundary=---------------------------7db7d61d023a' & @CRLF & _
'Host: ' & $HeUrl1 & @CRLF & 'Content-Length: ' & StringLen(BinaryToString($TxSendTxt)) & @CRLF & 'Connection: Keep-Alive' &@CRLF& _
'Cache-Control: no-cache'
FileWriteLine(@ScriptDir & '\日志.txt','提交地址:' & $HeaderUrl & "groupmail_send?sid=" & $Sid)
FileWriteLine(@ScriptDir & '\日志.txt','Header:' & $HeaderAdd)
FileWriteLine(@ScriptDir & '\日志.txt','提交内容:' & $TxSendTxt & @CRLF)
$rContext=_WinHTTP_GetRespond($MyOpen,$HeaderUrl & "groupmail_send?sid=" & $Sid,1 + 4 + 2,50000,$TxSendTxt,'',$HeaderAdd)
If @error Then MsgBox(0,@error,"出错了")
MsgBox(64,'Cookies',$rContext)
MsgBox(64,'编码类型',$rContext)
MsgBox(64,'完整Header',$rContext)
MsgBox(64,'数据内容',BinaryToString($rContext))
;FileWriteLine(@ScriptDir & '\日志.log','完整Header:' & $rContext)
;FileWriteLine(@ScriptDir & '\日志.log','数据内容:' & BinaryToString($rContext))
If StringInStr(BinaryToString($rContext),'发送成功') Then
MsgBox(64,'提示','邮件发送成功')
Else
MsgBox(48,'提示','邮件发送失败')
EndIf
Else
EndIf
GUICtrlSetState($Button2,$GUI_ENABLE)
EndFunc
Func _Get_Code()
$rContext=_WinHTTP_GetRespond($MyOpen,"https://mail.qq.com/cgi-bin/getverifyimage?aid=23000101&f=html&ck=1&"&@SEC ,4 + 2 ,50000)
If @error Then Return MsgBox(0,@error,"出错了")
$CodeFile = FileOpen(@TempDir & "\code.bmp",10)
FileWrite($CodeFile,Binary($rContext))
FileClose($CodeFile)
GUICtrlSetImage($Pic1,@TempDir & "\code.bmp")
EndFunc cookie肯定是要的.
你获取验证码的时候http头里就有返回cookie.
另外,我没有打击你的意思,我只是想说,你的做法实在太2了,还要验证码......
都到这地步了,为什么不去尝试研究下SMTP协议? curl或者smtp都比这个好.... 要cookies,curl比这个更好一下 回复 1# AUFS
既然用到我的UDF的话,我肯定得支声。
如果你网页版提交时,不需要Cookies的话,那么久应该是POST出问题了。
请用适用于全局截包的软件,看看你POST出什么内容,很有可能提交了一堆乱码(比实际长度小)。 回复 5# republican
明显是Cookies的问题,webMail都靠这个来保证的。
直接用协议来发信多简单多了 本帖最后由 AUFS 于 2011-4-13 12:18 编辑
感谢诸多老大来看给意见,小弟是最近才研究Winhttp的至于ceoguang 老大所说的SMTP协议,我还不了解。。先去了解一下,SMTP协议论坛里有没有相关的资料?下面我在论坛里搜到一个SMTP的UDF是不是这个呢?另外如果用SMTP来发的话如有需验证码又怎么获取和提交?如果多发的话可能会出限制出验证码之类的所以不知道是不是SMTP就可以无视限制了?
republican 老大(请用适用于全局截包的软件)我用的是httpwatchpro截的包,这个可以全局截包吗?
kadingxiaodi 老大(curl或者smtp都比这个好) curl的话百度了一下是一个很强的工具。。。但不知道返回信息怎么样。。就是有关于验证码里的返回和提交。。;~ Smtp Mailer
;http://www.autoitscript.com/forum/index.php?showtopic=23860&st=0
#Include<file.au3>
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$s_SmtpServer = "smtp.gmail.com" ; smtp服务器 address for the smtp-server to use - REQUIRED
$s_FromName = "www.yidabu.com" ; 邮件发送人 name from who the email was sent
$s_FromAddress = "your@gmail.com" ; 邮件发送者地址address from where the mail should come
$s_ToAddress = "your@gmail.com" ; 邮件发送给谁 destination address of the email - REQUIRED
$s_Subject = "bbs.yidabu.com" ;邮件标题 subject from the email - can be anything you want it to be
$as_Body = "autoit论坛" & @CRLF & _
"http://bbs.yidabu.com/forum-2-1.html" ; 邮件正文the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = "" ; 附件地址 the file you want to attach- leave blank if not needed
$s_CcAddress = "" ; address for cc - leave blank if not needed
$s_BccAddress = "" ; address for bcc - leave blank if not needed
$s_Username = "yidabu" ;用户名 username for the account used from where the mail gets sent - REQUIRED
$s_Password = "www.yidabu.com" ; 密码password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25 ; 发送端口 port used for sending the mail
$ssl = 0 ; 安全连接 enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465 ; yidabu.com提示:Gmail使用的发送端口
;~ $ssl=1 ; yidabu.com提示:Gmail要启用安全连接
;##################################
; Script
;##################################
Global $oMyRet
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
;~ $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
;~ If @error Then
;~ MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
;~ EndIf
;
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
$objEmail = ObjCreate("CDO.Message")
$objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
$objEmail.To = $s_ToAddress
Local $i_Error = 0
Local $i_Error_desciption = ""
If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
$objEmail.Subject = $s_Subject
If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then
$objEmail.HTMLBody = $as_Body
Else
$objEmail.Textbody = $as_Body & @CRLF
EndIf
If $s_AttachFiles <> "" Then
Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
For $x = 1 To $S_Files2Attach
$S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
If FileExists($S_Files2Attach[$x]) Then
$objEmail.AddAttachment ($S_Files2Attach[$x])
Else
$i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
SetError(1)
return 0
EndIf
Next
EndIf
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;Authenticated SMTP
If $s_Username <> "" Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
EndIf
If $Ssl Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
;Update settings
$objEmail.Configuration.Fields.Update
; Sent the Message
$objEmail.Send
if @error then
SetError(2)
return $oMyRet
EndIf
EndFunc ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet = $HexNumber
$oMyRet = StringStripWS($oMyError.description,3)
ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet & @LF)
SetError(1); something to check for when this function returns
Return
EndFunc ;==>MyErrFunc cookie肯定是要的.
你获取验证码的时候http头里就有返回cookie.
另外,我没有打击你的意思,我只是想说,你 ...
ceoguang 发表于 2011-4-13 02:12 http://www.autoitx.com/images/common/back.gif
这是验证码返回的Cookie
qm_authimgs_id=1; Domain=.qq.com; Path=/
qm_verifyimagesession=h00f84fa5568fdbac305813c711f9550a057551023775d717c7b8ba677afdfbc2de246086c8db72d0d5; Domain=.qq.com; Path=/
edition=m620.mail.qq.com; Domain=.mail.qq.com; Path=/; Expires=Fri, 13-Jun-2014 13:57:11 GMT
ssl_edition=m620.mail.qq.com; Domain=.mail.qq.com; Path=/
就是我这脚本里应该怎么去用这Cookie? 回复 8# AUFS
Domain指示Cookies适用的服务器,Path指示作用目录。
以‘qm_authimgs_id=1; Domain=.qq.com; Path=/‘为例,对于所有属于qq.com的N级域名,地址起始于’/‘的访问请求,更新Cookies为 'qm_authimgs_id=1'. $HeaderAdd = 'Accept-Language: zh-cn' & @CRLF & 'Content-Type: multipart/form-data; boundary=---------------------------7db7d61d023a' & @CRLF & _
'Host: ' & $HeUrl1 & @CRLF & 'Content-Length: ' & StringLen(BinaryToString($TxSendTxt)) & @CRLF & 'Connection: Keep-Alive' &@CRLF& _
'Cache-Control: no-cache'
$Cookies = 'qm_authimgs_id=1; Domain=.qq.com; Path=/' & @CRLF & 'qm_verifyimagesession=h00f84fa5568fdbac305813c711f9550a057551023775d717c7b8ba677afdfbc2de246086c8db72d0d5; Domain=.qq.com; Path=/' & @CRLF & _
'edition=m620.mail.qq.com; Domain=.mail.qq.com; Path=/; Expires=Fri, 13-Jun-2014 13:57:11 GMT' & @CRLF & 'ssl_edition=m620.mail.qq.com; Domain=.mail.qq.com; Path=/'
$rContext=_WinHTTP_GetRespond($MyOpen,$HeaderUrl & "groupmail_send?sid=" & $Sid,1 + 4 + 2,50000,$TxSendTxt,$Cookies,$HeaderAdd)这样用行不? 回复 10# AUFS
这是错误的用法。
Cookies只要填值就好了,domain等的信息是服务器告诉你怎样更新Cookeis的信息。
其次,host 你不需要填,winhttp会帮你填好。content-length该UDF也会帮你填。
想简单点的话,直接用SMTP服务;
Local $NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
$QQName = ''
$QQPassWord = ''
$Email = ObjCreate("CDO.Message")
$Email.From = $QQName & "@QQ.com"
$Email.To= $QQName & "@QQ.com"
$Email.Subject = '测试'
$Email.Textbody = '测试'
;~ For $i = 1 To $WebMailSendAttatch
;~ $Email.AddAttachment ($WebMailSendAttatch[$i])
;~ Next
With $Email.Configuration.Fields
.Item($NameSpace&"sendusing") = "2"
.Item($NameSpace&"smtpserver") = "smtp.qq.com"
.Item($NameSpace&"smtpserverport") = "25"
.Item($NameSpace&"smtpauthenticate") = "1"
.Item($NameSpace&"sendusername") = $QQName
.Item($NameSpace&"sendpassword") = $QQPassWord
.Update
EndWith
$Email.Send 测试了一下代码,出错提示 请求动作失败(请求于对象) $Email.Send
55267365@groupmail.qq.com 发这样的地址也可以发?用SMTP 不好意思..是我的邮箱没开SMTP服务...打开之后邮件可以正常发送... 这个SMTP普通邮件是可以发送但像55267365@groupmail.qq.com 这样的地址就不能发送了....
因为可能会出现验证码的原因,还是用Winhttp去试着完成...现在想知道这个Cookies的用法是怎么样用...请教..下面的Cookies应该怎么取值写进
$rContext=_WinHTTP_GetRespond($MyOpen,$HeaderUrl & "groupmail_send?sid=" & $Sid,1 + 4 + 2,50000,$TxSendTxt,写进这里,$HeaderAdd)
另Header这里这样填?关于Winhttp的使用方法还不是很了解...劳烦老大了
$HeaderAdd = 'Accept-Language: zh-cn' & @CRLF & 'Content-Type: multipart/form-data; boundary=---------------------------7db7d61d023a' & @CRLF & _
'Connection: Keep-Alive' &@CRLF & 'Cache-Control: no-cache'
qm_authimgs_id=1; Domain=.qq.com; Path=/
qm_verifyimagesession=h00f84fa5568fdbac305813c711f9550a057551023775d717c7b8ba677afdfbc2de246086c8db72d0d5; Domain=.qq.com; Path=/
edition=m620.mail.qq.com; Domain=.mail.qq.com; Path=/; Expires=Fri, 13-Jun-2014 13:57:11 GMT
ssl_edition=m620.mail.qq.com; Domain=.mail.qq.com; Path=/ 如果实在要用WEB方式的话cookie只需要下面这个.qm_verifyimagesession=h00f84fa5568fdbac305813c711f9550a057551023775d717c7b8ba677afdfbc2de246086c8db72d0d5
页:
[1]
2