Proporcjonalna czcionka Temat: Biblioteka CDO.Message nie chce współpracować po SSL'u z postfixem
Autor: Marcin Gala Data: 10 Wrz 2008
Odwołania:
Odpalam skrypt do wysyłki maila korzystając z CDO.Message, ustawiam SSL, podaje dane do autoryzacji i połączenie jest zrywane nie wiadomo czemu :( szukam przyczyny zrywania połączenia z postfixem Skrypt: ' CDO script to send email ' Modify EMAILAddrFrom, EMAILAddrTo, SMTPSvr and file name in AddAttachment as appropriate ' ' www.sandlerco.com ' Function CheckError(strDetails) Dim strErr If Err.Number <> 0 then strErr = strDetails & " : Exception " & Err.Description & " err.Number=0x" & _ Hex(Err.Number) & " source=" & Err.Source MsgBox strErr Err.Clear CheckError = False else WScript.echo strDetails & " - success" CheckError = True End If End Function const EMAILAddrFrom = "lo...@domena.pl" const SMTPSvr = "mail.domena.pl" const EMAILAddrTo = "drugiad...@domena.sh" const SEND_METHOD = 2 ' cdoSendUsingPort const cdoBasic = 1 const cdoAnonymous = 0 Sub MailTest On Error Resume Next Dim Msg Set Msg = Wscript.CreateObject("CDO.Message") If CheckError("CreateObject(CDO.Message)") <> True then Exit Sub End If WScript.echo "CDO.Message created" Dim Conf Set Conf = Wscript.CreateObject("CDO.Configuration") If CheckError("CreateObject(CDO.Configuration)") <> True then Exit Sub End If WScript.echo "CDO.Configuration created" Dim Flds Set Flds = Conf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/ sendusing") = 2 ' cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/ smtpserver") = SMTPSvr .Item("http://schemas.microsoft.com/cdo/configuration/ smtpconnectiontimeout") = 60 ' quick timeout ' cdoAnonymous ' .Item("http://schemas.microsoft.com/cdo/configuration/ smtpauthenticate") = cdoAnonymous ' .Item("http://schemas.microsoft.com/cdo/configuration/ smtpserverport") = 25 ' cdoBasic '.Item("http://schemas.microsoft.com/cdo/configuration/ smtpauthenticate") = cdoBasic '.Item("http://schemas.microsoft.com/cdo/configuration/ sendusername") = "UserName" '.Item("http://schemas.microsoft.com/cdo/configuration/ sendpassword") = "Password" ' cdoBasic with SSL .Item("http://schemas.microsoft.com/cdo/configuration/ smtpauthenticate") = cdoBasic .Item("http://schemas.microsoft.com/cdo/configuration/ sendusername") = "login" .Item("http://schemas.microsoft.com/cdo/configuration/ sendpassword") = "" .Item("http://schemas.microsoft.com/cdo/configuration/ smtpusessl") = "true" .Item("http://schemas.microsoft.com/cdo/configuration/ smtpserverport") = 25 .Update End With If CheckError("Conf.Fields assign") <> True then Exit Sub End If WScript.echo "Conf.Fields assigned" With Msg Set .Configuration = Conf .To = EMAILAddrTo ' if From is used, the recipient has <Sender> on behalf of <From>, reply goes to <From> .From = EMAILAddrFrom .Sender = EMAILAddrFrom .Subject = "Test" .TextBody = "Test" '.AddAttachment "file://c:/btest.tiff" ' DSNOptions - request for a receipt of message delivery status - delivery receipt options (RFC 1894) ' cdoDSNDefault 0 No DSN commands are issued. ' cdoDSNNever 1 No DSN commands are issued. ' cdoDSNFailure 2 Return a DSN if delivery fails. ' cdoDSNSuccess 4 Return a DSN if delivery succeeds. ' cdoDSNDelay 8 Return a DSN if delivery is delayed. ' cdoDSNSuccessFailOrDelay 14 Return a DSN if delivery succeeds, fails, or is delayed. .DSNOptions = 0 ' cdoDSNDefault ' see known problem 2 below (re: SSL) ' Add custom header if required ' .Fields("urn:schemas:mailheader:XYZcustom") = "my custom header" .Fields.Update .Send End With If CheckError("MailTest") <> True then Exit Sub End If WScript.echo "Success" End Sub MailTest() '--------------------------------------------------------- ' Known CDO problems '1. Vista - MDNRequested = "true" - CDO miserably fails (but email is still delivered) ' Request the 'read receipt'. It will be sent when the recipient reads/ deletes the message, 'read receipt' will be located ' in cdoDisposition ("urn:schemas:mailheader:disposition") field, see RFC 2298 ' Msg.MDNRequested = "true" ' - make sure cdoDispositionNotificationTo is filled in ' Msg.Fields("urn:schemas:mailheader:disposition-notification- to") = EMAILAddr ' Msg.Fields("urn:schemas:mailheader:return-receipt-to") = EMAILAddr ' '2. Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true" and DSNOptions = 4 or similar - CDO either fails ' or does not report error, but email is never delivered - tested with gmail.com '------------------------------------------------------------ Logi z komunikat TLS: Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 220 siec.mine.nu ESMTP Postfix (Ubuntu) Sep 8 17:05:18 xeon postfix/smtpd[2830]: < unknown[80.50.125.74]: EHLO Kronos Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- siec.mine.nu Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- PIPELINING Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- SIZE 10240000 Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- VRFY Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- ETRN Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- STARTTLS Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- AUTH PLAIN Sep 8 17:05:18 xeon postfix/smtpd[2830]: match_list_match: unknown:no match Sep 8 17:05:18 xeon postfix/smtpd[2830]: match_list_match: 80.50.125.74: no match Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- AUTH=PLAIN Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250- ENHANCEDSTATUSCODES Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250-8BITMIME Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 250DSN Sep 8 17:05:18 xeon postfix/smtpd[2830]: < unknown[80.50.125.74]:STARTTLS Sep 8 17:05:18 xeon postfix/smtpd[2830]: > unknown[80.50.125.74]: 220 2.0.0 Ready to start TLS Sep 8 17:05:18 xeon postfix/smtpd[2830]: setting up TLS connection from unknown[80.50.125.74] Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr request = seed Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr size = 32 Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/tlsmgr: wanted attribute: status Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: status Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute value: 0 Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/tlsmgr: wanted attribute: seed Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: seed Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute value: 0CF2zPaARjYGasaas0v7/R0/y7j7ODxyk5eQ7k= Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/tlsmgr: wanted attribute: (list terminator) Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: (end) Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr request = update Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr cache_type = smtpd Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr cache_id = 04E1382E58235DF56C55BA01829E453C01844C9EAAC10069326692B396&s=smtp Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr session = [data 127 bytes] Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/tlsmgr: wanted attribute: status Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: status Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute value: 0 Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/tlsmgr: wanted attribute: (list terminator) Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: (end) Sep 8 17:05:18 xeon postfix/smtpd[2830]: Anonymous TLS connection established from unknown[80.50.125.74]: TLSv1 with cipher AES128-SHA (128/128 bits) Sep 8 17:05:18 xeon postfix/smtpd[2830]: smtp_get: EOF Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr request =disconnect Sep 8 17:05:18 xeon postfix/smtpd[2830]: send attr ident = smtp: 80.50.125.74 Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/anvil: wanted attribute: status Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: status Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute value: 0 Sep 8 17:05:18 xeon postfix/smtpd[2830]: private/anvil: wanted attribute: (list terminator) Sep 8 17:05:18 xeon postfix/smtpd[2830]: input attribute name: (end) Sep 8 17:05:18 xeon postfix/smtpd[2830]: lost connection after STARTTLS from unknown[80.50.125.74] Sep 8 17:05:18 xeon postfix/smtpd[2830]: disconnect from unknown[80.50.125.74] Sep 8 17:05:18 xeon postfix/smtpd[2830]: master_notify: status 1 Sep 8 17:05:18 xeon postfix/smtpd[2830]: connection closed Sep 8 17:05:22 xeon postfix/smtpd[2830]: proxymap stream disconnect Sep 8 17:05:23 xeon postfix/smtpd[2830]: auto_clnt_close: disconnect private/tlsmgr stream Nie mogę doprowadzić tego skryptu do działania, nie ma dokładniejszych logów z Visual Basic'a :( Dlaczego to nie działa?