SendMail的SMTP连接:身份验证失败

时间:2016-06-23 13:11:41

标签: authentication vbscript smtp sendmail

我正面临着一个'服务器响应是:530 5.7.1需要验证'尽管提供了身份验证凭据以下是我的SendMail.vbs



Const ForReading = 1, ForWriting = 2, ForAppending = 8 

Dim ArgTo_s
Dim ArgSubject_s
Dim ArgMsgAttachFile_s
Dim ArgMsgBodyFile_s

ArgTo_s = ""
ArgSubject_s = ""
ArgMsgAttachFile_s = ""
ArgMsgBodyFile_s = ""

ArgTo_s = Wscript.Arguments(0)
ArgSubject_s = Wscript.Arguments(1)
ArgMsgBodyFile_s = Wscript.Arguments(2)

IF Wscript.Arguments.count > 3 then 
  ArgMsgAttachFile_s = Wscript.Arguments(3)
End If

SMTPServerName_s = "smtp.rediffmail.com"

' -- Open file and get message body -- Start --
Set MsgBody_fso = CreateObject("Scripting.FileSystemObject")
Set MsgBody_file = MsgBody_fso.OpenTextFile(ArgMsgBodyFile_s, ForReading)
MsgBody_s = MsgBody_file.ReadAll
MsgBody_file.Close
Set MsgBody_file = Nothing
Set MsgBody_fso = Nothing
' -- Open file and get message body -- End --

' -- Get the Hostname Start --
Set Shell_o = CreateObject("WScript.Shell")
RegValue_s = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname"
HostName_s = Shell_o.RegRead(RegValue_s)
' -- Get the Hostname End --

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = ArgSubject_s & " (Anonymous Application EMail)"
objMessage.From = UCase("test@myconsulting.co.in")
objMessage.To = ArgTo_s
objMessage.TextBody = MsgBody_s

If ArgMsgAttachFile_s <> "" Then
  objMessage.AddAttachment ArgMsgAttachFile_s
End If


objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "test@myconsulting.co.in"

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "100000567"

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.rediffmail.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

objMessage.Configuration.Fields.Update

objMessage.Send
&#13;
&#13;
&#13;

以下是屏幕截图: enter image description here

1 个答案:

答案 0 :(得分:0)

虽然您添加了用户名和密码,但您的脚本似乎并没有告诉服务器进行身份验证。

尝试添加以下代码:

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic