Author Topic: Mail Auth Login test  (Read 3100 times)

0 Members and 1 Guest are viewing this topic.

Offline Pierre Bellisle

  • Jr. Member
  • **
  • Posts: 82
  • User-Rate: +11/-7
Mail Auth Login test
« on: August 29, 2010, 10:02:16 PM »
I'm testing a SendMail program with the AUTH LOGIN option
and want to know if my isp respond differently when the query
come from from his server or from another one.
I'd appreciate if someone can run the CC code
and send me bak the result via a PM.

Note that the result will be automatiquely putted in the clipboarb.

Please send the result via a PM.

Thank
Pierre

Code: [Select]
#COMPILE EXE '#CC 4.04#
#DIM ALL
#INCLUDE "WIN32API.INC"
#INCLUDE "IPHLPAPI.INC"
'______________________________________________________________________________

FUNCTION ClipBoardWrite(BYVAL sBuffer AS STRING) AS LONG
 LOCAL hClipboard  AS DWORD
 LOCAL pData       AS ASCIIZ PTR
 LOCAL hData       AS DWORD

 IF IsClipboardFormatAvailable(%CF_TEXT) THEN
   hClipboard = GlobalAlloc(%GMEM_MOVEABLE, LEN(sBuffer) + 1) '%GMEM_MOVEABLE OR %GMEM_ZEROINIT
   IF hClipboard THEN
     pData  = GlobalLock(hClipboard)
     @pData = sBuffer & $NUL
     GlobalUnlock(hClipboard)
     IF OpenClipboard(0) THEN
       EmptyClipboard
       hData = SetClipboardData(%CF_TEXT , hClipboard)
       IF hData THEN FUNCTION = %TRUE 'Success
       CloseClipboard
     ELSE
       GlobalFree hData
     END IF
   END IF
 END IF

END FUNCTION
'______________________________________________________________________________

FUNCTION SendMail(MailHost AS STRING, MailPort AS DWORD, Helo AS STRING) AS LONG
 LOCAL sBuffer    AS STRING
 LOCAL sLocalHost AS STRING
 LOCAL hTcp       AS DWORD
 LOCAL ErrorCode  AS LONG

 HOST ADDR TO hTCP
 HOST NAME hTCP TO sLocalHost
 hTCP = FREEFILE

 COLOR 11
 TCP OPEN PORT MailPort AT MailHost AS hTCP '587 for Videotron international, 25 for Videotron local
 STDOUT "TCP OPEN PORT" & STR$(MailPort) & " AT " & MailHost & " AS " & HEX$(hTcp)

 IF ERR THEN
   sBuffer = "Error connecting to mailhost"
   GOTO Quit
 ELSE
   COLOR 14
   DO WHILE NOT EOF(hTCP)
     TCP LINE hTCP, sBuffer
     STDOUT sBuffer
     ErrorCode = VAL(LEFT$(sBuffer, 3))
   LOOP
   IF ErrorCode <> 220 THEN GOTO Quit
 END IF

 TCP PRINT hTCP, Helo & $SPC & sLocalHost
 COLOR 11
 STDOUT Helo & $SPC & sLocalHost
 COLOR 14
 DO WHILE NOT EOF(hTCP)
   TCP LINE hTCP, sBuffer
   STDOUT sBuffer
   ErrorCode = VAL(LEFT$(sBuffer, 3))
 LOOP
 IF ErrorCode <> 250 THEN GOTO Quit

 TCP PRINT hTCP, "AUTH LOGIN"
 COLOR 11
 STDOUT "AUTH LOGIN"
 COLOR 14
 DO WHILE NOT EOF(hTCP)
   TCP LINE hTCP, sBuffer
   STDOUT sBuffer
   ErrorCode = VAL(LEFT$(sBuffer, 3))
 LOOP
 IF ErrorCode <> 334 THEN GOTO Quit

 Quit:

 TCP PRINT hTCP, "QUIT"
 COLOR 11
 STDOUT "QUIT"
 COLOR 14
 DO WHILE NOT EOF(hTCP)
   TCP LINE hTCP, sBuffer
   STDOUT sBuffer
   ErrorCode = VAL(LEFT$(sBuffer, 3))
 LOOP

 TCP CLOSE hTCP
 COLOR 7

 END FUNCTION
'______________________________________________________________________________

FUNCTION PBMAIN() AS LONG
 LOCAL ConsoleText AS STRING * 30000
 LOCAL MailHost    AS STRING
 LOCAL MailPort    AS DWORD
 LOCAL sBuffer     AS STRING
 LOCAL sLine       AS STRING
 LOCAL Count       AS LONG

 SetConsoleScreenBufferSize(GETSTDOUT,  MAKDWD(750, 800)) 'MAKDWD(wCol, wRow)
 SetWindowPos(CONSHNDL, %NULL, 1, 1, 750, 800, %SWP_NOZORDER) 'Xpos, Ypos, Xsize, Ysize

 MailHost = "smtp.myownmail.com" 'port 25 ou 587 international
 MailPort = 587 '587 or 25

 STDOUT "--------------------------------------------------------------------"
 SendMail(MailHost, MailPort, "HELO")
 STDOUT "--------------------------------------------------------------------"
 SendMail(MailHost, MailPort, "EHLO")
 STDOUT "--------------------------------------------------------------------"

 ReadConsoleOutputCharacter(GetStdHandle(%STD_OUTPUT_HANDLE), BYVAL VARPTR(ConsoleText), _
                            BYVAL SIZEOF(ConsoleText), BYVAL MAKDWD(0, 0), Count)

 OemToCharBuff BYVAL VARPTR(ConsoleText), BYVAL VARPTR(ConsoleText), SIZEOF(ConsoleText)

 Count = 0
 DO
   sLine = RTRIM$(MID$(ConsoleText, 750 * Count + 1, 750))
   IF LEN(sLine) = 0 THEN EXIT DO
   sBuffer = sBuffer & sLine & $CRLF
   INCR Count
 LOOP

 ClipBoardWrite(sBuffer)

 PRINT "Data is in the clipboard, thank you !"

 MOUSE ON : MOUSE 3, UP : PRINT : PRINT "Strike any key or click..." : WAITKEY$

END FUNCTION
'______________________________________________________________________________
'
« Last Edit: October 25, 2013, 09:24:02 PM by Pierre Bellisle »

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2483
  • User-Rate: +204/-0
Re: Mail Auth Login test
« Reply #1 on: August 29, 2010, 10:59:10 PM »
PM sent.

Offline Pierre Bellisle

  • Jr. Member
  • **
  • Posts: 82
  • User-Rate: +11/-7
Mail Auth Login test
« Reply #2 on: August 30, 2010, 12:59:58 AM »
Exactly what I was hoping for.
Authentification is enabled only when not directly connected to their server.

Thank you José Roca  :)