Jump to content

Recommended Posts

Posted (edited)

Here I found a usefull UDF for POP3.

I modified this UDF.

You can download it from download section.

POP3_v2.jpg.f349c1b3a1841cfc8782bdfdc720


Below you see old description:

  Reveal hidden contents

 

Edited by mLipok
+screenshot

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

8 downloads .. no comments ?
 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

  On 2/10/2015 at 7:41 PM, mLipok said:

8 downloads .. no comments ?

You have 2753 posts so far and you really ask that question? And further after 8! downloads?  :shocked:

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
Thanks for your comment.
I was thinking about more constructive comments.
 
But this was also instructive.
 
I'll try to be more patient.
 
mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 months later...
Posted

Thanks for the library it was a great help. I was able to successfully implement it in a small program with some minor modifications.

I have the same issue as has been identified but apparently not resolved where the Parser fails with an array violation.

I found the issue to be the emails that I am reading do not have 'boundary=' lines so the _ArraySearch function returns a -1 which is causes the failure as the array reference.

For my purposes the content of the email follows the MIME-version: header and the content is simple unformatted text. I decided to deliver the content in my array as one element per line excluding the blank lines. I substituted the following code: 

Func _POP3_EML_Parser($sEML_Contents)
    Local $aLetter[1]
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^From: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^To: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?im)^Subject: +(.*)\r\n', 1), $aLetter)
    __POP3_EML_Parser_AddToLetterArray(StringRegExp($sEML_Contents, '(?i)charset="?(.*?)(?:"|\r\n)', 1), $aLetter)
    Local $aSplit = StringSplit($sEML_Contents, @CRLF, 1)
    Local $boundary1 = _ArraySearch($aSplit, "MIME-Version:", 0, 0, 0, 1) + 1
    Local $boundary2 = UBound($aSplit)
    Local $sMessage = ""
    Local $bWrite = False
    For $i = $boundary1 To $boundary2 - 1
            If $aSplit[$i] <> "" Then __POP3_EML_Parser_AddToLetterArray($aSplit[$i], $aLetter)
    Next
    Return $aLetter
EndFunc   ;==>_POP3_EML_Parser

I didn't research very far into the formatting mysteries that appear to be happening. I just made some code that worked for this one need. If I have some time I may come back to look at this.
 

  • 4 months later...
  • 7 months later...
Posted

Sorry for late repy:

http://www.ietf.org/rfc/rfc1939.txt

  Quote
   When the client issues the QUIT command from the TRANSACTION state,
   the POP3 session enters the UPDATE state.  (Note that if the client
   issues the QUIT command from the AUTHORIZATION state, the POP3
   session terminates but does NOT enter the UPDATE state.)

   If a session terminates for some reason other than a client-issued
   QUIT command, the POP3 session does NOT enter the UPDATE state and
   MUST not remove any messages from the maildrop.

      QUIT

         Arguments: none

         Restrictions: none

         Discussion:
             The POP3 server removes all messages marked as deleted
             from the maildrop and replies as to the status of this
             operation.  If there is an error, such as a resource
             shortage, encountered while removing messages, the
             maildrop may result in having some or none of the messages
             marked as deleted be removed.  In no case may the server
             remove any messages not marked as deleted.

             Whether the removal was successful or not, the server
             then releases any exclusive-access lock on the maildrop
             and closes the TCP connection.
Expand  

 

but I see other problem .... working on.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  Quote
9. POP3 Command Summary

      Minimal POP3 Commands:

         USER name               valid in the AUTHORIZATION state
         PASS string
         QUIT

         STAT                    valid in the TRANSACTION state
         LIST [msg]
         RETR msg
         DELE msg
         NOOP
         RSET
         QUIT
Expand  

This should work:

#include <array.au3>
#include <FileConstants.au3>
#include "_POP3_Ex.au3"
#include "Quoted-printable.au3"

Global $sPOP3_MyPopServer = "XXXXX"
Global $sPOP3_MyLogin = "XXXXX"
Global $sPOP3_MyPasswd = "XXXXX"


;~ _POP3_ServerResponseTimeOut(60000)
_POP3_ConsoleDebugSatus(True)

_POP3_ServerConnect($sPOP3_MyPopServer)
If @error Then MsgBox($MB_ICONERROR, 'Connect', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

_POP3_ServerLogIn($sPOP3_MyLogin, $sPOP3_MyPasswd)
If @error Then MsgBox($MB_ICONERROR, 'LogIn','@error = ' & @error & @CRLF & '@extended = ' & @extended)


_POP3_RFC_LIST(1)
_POP3_RFC_RETR(1)
_POP3_EML_SaveToFile(1, @ScriptDir & '\Test_'& @YEAR & @MON & @MDAY & '_' & @HOUR&@MIN & @SEC &'.eml')
If @error Then MsgBox($MB_ICONERROR, 'SAVE', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

_POP3_RFC_DELE(1)
If @error Then MsgBox($MB_ICONERROR, 'DELE', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

new version:

  Quote

    2016/05/04 ver. 2.0.1
    .    Renamed:     UDF:    _POP3_Ex.au3 >> POP3.au3 - mLipok
    .    Renamed:     Var:    $g__iPOP3_SOCKET >> $__g_iPOP3_SOCKET - mLipok
    .    Renamed:     Var:    $POP3_OK >> $POP3_REGEXP_OK - mLipok
    .    New:         Var:    $POP3_REGEXP_ERR - mLipok
    .    New:         Var:    $POP3_REGEXP_PASS - mLipok
    .    New:         Var:    $POP3_CALLBACK_COMMAND - mLipok
    .    New:         Var:    $POP3_CALLBACK_STATUS - mLipok
    .    Renamed:     Enums:     $POP3_ERROR_* >> $POP3_ERR_* - mLipok
    .    Renamed:     Enum:     $POP3_ERR_OK >> $POP3_ERR_SUCCESS - mLipok
    .    Renamed:     Enum:     $POP3_ERR >> $POP3_ERR_GENERAL - mLipok
    .    Renamed:     Enum:     $POP3_ERR_SERVER_RESPONSE_TIMEOUT >> $POP3_ERR_TIMEOUT - mLipok
    .    Renamed:     Enum:     $POP3_ERR_TCPRECV_TIMEOUT >> $POP3_ERR_TIMEOUT - mLipok
    .    Renamed:     Enum:     $POP3_ERR_TCPCONNECT_FAILED >> $POP3_ERR_TCPCONNECT - mLipok
    .    New:         Enum:     $POP3_ERR_TCPSTARTUP - mLipok
    .    New:         Enum:     $POP3_ERR_SSL - mLipok
    .    New:         Enum:     $POP3_EXT_CONNECTED - mLipok
    .    New:         Enum:     $POP3_ERR_TCPRECV - mLipok
    .    New:        Func:     _POP3_UDFVersion - mLipok
    .    Removed:     Enum:     $POP3_ERR_ALREADY_CONNECTED --> Check for $POP3_EXT_CONNECTED - mLipok
    .    Removed:     Enum:     $POP3_ERR_NO_TCP_RESPONSE - is no longer used - mLipok
    .    Removed:     Enum:     $POP3_ERR_NO_OK_RESPONSE - is no longer used - mLipok
    .    Renamed:     Func:    __POP3_Cmd >> __POP3_SendCommand - mLipok
    .    Renamed:     Func:    _POP3_ConsoleDebug >> _POP3_Callback - mLipok
    .    Renamed:     Func:    _POP3_ConsoleError >> _POP3_CallbackError - mLipok
    .    Removed:     Func:    _POP3_CallbackSatus --> _POP3_Callback(FirstClassFunction) - mLipok
    .    Renamed:     Func:    _POP3_ServerIsConnected >> _POP3_IsConnected - mLipok
    .    Renamed:     Func:    _POP3_ServerIsAuth >> _POP3_IsAuthorized - mLipok
    .    Removed:    Func:     _POP3_CallbackFunction - mLipok
    .    Refactored: Func:    _POP3_IsConnected - mLipok
    .    Refactored: Func:    _POP3_IsAuthorized - mLipok
    .    Refactored: Func:     _POP3_RFC_... Functions: Finally correctly reporting: $POP3_ERR_**_REFUSED - mLipok
    .    Refactored: Func:     All faunction - mLipok
    .                If _POP3_IsAuthorized() Then  >>> checking @error
    .    Refactored: Func:    @error handling almost all functions - mLipok
    .                If @error Then Return SetError(@error, @extended, .......
    .    Refactored:    Var:    Magic Number replaced with Const/Enums - mLipok
 

Expand  

 

Download link.

Regards,
mLipok

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

BEWARE: do not use Magic Number in @error checking.
Name and order can be changed in the future - for this reason I recommend using  $POP3_ERR_*  enumerated constants.

 


Some reference documentation:  https://tools.ietf.org/html/rfc1939

 


Example:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#include <array.au3>
#include <FileConstants.au3>
#include "POP3.au3"
#include "Quoted-printable.au3"

ConsoleWrite('POP3.au3 UDF v.' & _POP3_UDFVersion() & @CRLF)
ConsoleWrite('@AutoItVersion=' & @AutoItVersion & @CRLF)

Global $sPOP3_MyPopServer = "xxxx"
Global $sPOP3_MyLogin = "xxxx"
Global $sPOP3_MyPasswd = "xxxx"

;~ _POP3_ServerResponseTimeOut(60000)
_POP3_Callback(_MyPOP3_Callback)
_POP3_CallbackError(_MyPOP3_CallbackError)

_Example_1()
If @error Then MsgBox($MB_ICONERROR, '_Example_1', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

_Example_2_UIDL()
If @error Then MsgBox($MB_ICONERROR, '_Example_1', '@error = ' & @error & @CRLF & '@extended = ' & @extended)

Func _Example_1()
    _POP3_ServerConnect($sPOP3_MyPopServer)
    If @error Then Return SetError(@error, @extended, '')

    _POP3_ServerLogIn($sPOP3_MyLogin, $sPOP3_MyPasswd)
    If @error Then Return SetError(@error, @extended, '')

    _POP3_RFC_LIST(1)
    If @error Then Return SetError(@error, @extended, '')

    Local $sEMLFile = @ScriptDir & '\Test_' & @YEAR & @MON & @MDAY & '_' & @HOUR & @MIN & @SEC & '.eml'
    _POP3_EML_SaveToFile(1, $sEMLFile)
    If @error Then Return SetError(@error, @extended, '')

;~  _POP3_RFC_DELE(1)
;~  If @error Then Return SetError(@error, @extended, '')

    _POP3_RFC_QUIT()
    If @error Then Return SetError(@error, @extended, '')

    _POP3_ServerDisconnect()
EndFunc   ;==>_Example_1

Func _Example_2_UIDL()
    _POP3_ServerConnect($sPOP3_MyPopServer)
    If @error Then Return SetError(@error, @extended, '')

    _POP3_ServerLogIn($sPOP3_MyLogin, $sPOP3_MyPasswd)
    If Not @error Then
        Local $aUIDL = _POP3_RFC_UIDL()
        If Not @error Then _ArrayDisplay($aUIDL, '_POP3_RFC_UIDL() Results')

        _POP3_RFC_QUIT()
    EndIf

    _POP3_ServerDisconnect()
EndFunc   ;==>_Example_2_UIDL

Func _MyPOP3_Callback($sText)
    ConsoleWrite($sText)
EndFunc   ;==>_MyPOP3_Callback

Func _MyPOP3_CallbackError($sText)
    ConsoleWrite('! ' & $sText)
EndFunc   ;==>_MyPOP3_CallbackError

 

POP3_v2.jpg.f349c1b3a1841cfc8782bdfdc720

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 1 year later...
Posted

Many Thanks!

But i'm getting an error:

_POP3_ServerConnect: connecting to: xxx.xxxxx.com  - using port: 110
xxx.xxxxxx.com >> xx.xxx.xxx.xxx
! [ 10060 / 0 ]   _POP3_ServerConnect: Error: $POP3_ERR_TCPCONNECT

I think is not a problem with the port or server name because same values are working with two command line pop clients:

  1. popclient (very good)
  2. and a quiet old 'getmail for windows' (not the same as this other getmail that looks very proffesional but difficult to install on windows)

The hosting provider I am using is Dreamhost. I've tested changing server name for 'cluster name' as explained here:

But always the same error codes: 5, extended 10060

Tested in XP and Windows 10

 

Posted

Maybe your server require some security like SSL or TLS ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Surprisingly, new test from the office pc (windows 7) and JUST WORKS!,

without any changes

_POP3_ServerConnect: connecting to: XXX.XXXXXX.com  - using port: 110
XXX.XXXXXXX.com >> XX.XXX.XXX.XXX
< S: +OK Dovecot ready.
> C: USER xxxxxxx@xxxxx.com
< S: +OK
> C: PASS XXXXXXXX
< S: +OK Logged in.

Maybe my tests from home were using some kind of less secure conexion that is rejected by DreamHost.

i was using low cost tech: and old xp laptop connected toa a quite old mobile phone (Android 2 i think) as modem (tethering)

not very releably ...

Many Thanks mLipok for alls your work in the forum

Posted (edited)
  On 2/26/2018 at 8:13 AM, robertocm said:

Maybe my tests from home were using some kind of less secure conexion that is rejected by DreamHost.

i was using low cost tech: and old xp laptop connected toa a quite old mobile phone (Android 2 i think) as modem (tethering)

Expand  

Just to report that i've made a new test with the 'low cost tech' and WORKING! through stunnel

I've read this from hevoxer, 2012

  Quote

It is easy to do that these functions to work with SSL. All we need is install stunnel.

Expand  

He also explains very well how to install stunnel and configure it in this post, see his example of 'Configuration file for stunnel for POP3.'

Following this instructions i've edited the example stunnel.conf file in the config folder. All lines comented except:

; **************************************************************************
; * Service defaults may also be specified in individual service sections  *
; **************************************************************************
; Certificate/key is needed in server mode and optional in client mode

cert = stunnel.pem

;...

; Disable support for insecure SSLv2 protocol

options = NO_SSLv2

;...

; **************************************************************************
; * Service definitions (at least one service has to be defined)           *
; **************************************************************************

; ***************************************** Example TLS client mode services

; Example SSL client mode services

[pop3]
client = yes
;This means that stunnel works in client mode
accept = 127.0.0.1:110
;Port number on our machine on which stunnel will be listen to incoming non-ciphered connection. By default if POP3 is non secured 110 is the port on which it works. That could be any other free port.
connect = my.emailserver.com:995
;on this server and port, stunnel redirect connection incoming on localhost 110 but now it will be ssl secured. And that's it! CHANGE SERVER NAME TO YOUR OWN!!!

And finally, just changed a line in POP3_Example.au3:

;comented this
;Global $sPOP3_MyPopServer = "my.emailserver.com"
;replaced for this
Global $sPOP3_MyPopServer = "127.0.0.1"

And gets connection:

POP3.au3 UDF v.2.0.1
@AutoItVersion=3.3.14.2
! [ 9 / 0 ]   _POP3_IsConnected: $POP3_ERR_NOT_CONNECTED
_POP3_ServerConnect: connecting to: 127.0.0.1  - using port: 110
< S: +OK Dovecot ready.
> C: USER myusername@emailserver.com
< S: +OK
> C: PASS XXXXXXXX
< S: +OK Logged in.

 

Note: execute the stunnel installer from a path without spaces (the installer doesn't seems to like paths with spaces, at least in my case, i needed to move the installer to another path without spaces)

Edited by robertocm

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...