Jump to content



Photo

_pop3 UDF, according to the 1939 RFC


  • Please log in to reply
32 replies to this topic

#1 Apzo

Apzo

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 09 March 2006 - 05:51 PM

Hello

I made a set of pop3 functions, based on the pop3 RFC and the wonderfull abilities of the 3.1.1.110 au3 beta version.

You will find in the zip file a sample script, and of course the library.

The functions are :
_pop3Connect (server, login, passwd [, port]) _Pop3Dele(msg_number) _Pop3List([msg_number]) _Pop3Noop() _Pop3Quit() _Pop3Retr(msg_number) _Pop3Rset() _Pop3Stat() _Pop3Top(msg_number, lines) _Pop3Uidl([msg_number])


I'm sure you bot coders will love it :o

Have fun !
Apzo.

[Edit]
2008, Oct 29.
Thanks to Alexandre Beloin, the _pop3Disconnect() has been updated.
The zip file has been updated too.
[/Edit]

Attached Files


Edited by Apzo, 29 October 2008 - 01:54 PM.






#2 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 09 March 2006 - 06:29 PM

sounds cool, I'll look at it later. BTW what login method do you use? plain text?

Edited by mikeytown2, 09 March 2006 - 06:30 PM.


#3 Apzo

Apzo

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 09 March 2006 - 08:10 PM

sounds cool, I'll look at it later. BTW what login method do you use? plain text?


Plain text, yes, the good old login/pass on port 110 is still a major security hole :o

However I'm trying to understand the APOP mechanism, it uses md5 but I don't know if my ISP currently support it.

I'll tell here about new enhancements.

Apzo.

#4 KxS

KxS

    Seeker

  • Active Members
  • 16 posts

Posted 09 March 2006 - 08:47 PM

Looks great, will check it out.

How does it handle attachments?

#5 Gigglestick

Gigglestick

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 501 posts

Posted 09 March 2006 - 09:40 PM

That's great! Can you make an IMAP one one? :o
My UDFs: ExitCodes

#6 Apzo

Apzo

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 10 March 2006 - 08:35 AM

Looks great, will check it out.

How does it handle attachments?


Attachments are not part of the POP3 protocol.
The mails are text encoded in the mailbox, and retrieved as text.

If you need to handle attachments, I've seen a base64 UDF around here that may suit your needs.

EDIT : attachments rather need a mime decoder, kinda great challenge !
Some work for Mikeytown2 and Blindwig ?


That's great! Can you make an IMAP one one? :sorcerer:


Why not ? It may be a great copy/paste party, but it shouldn't be difficult ;)

I'm thinking about some other protocols, such as SMTP and IRC :o
It's easy now to code net protocols with the new net and regexp functions :geek:


Apzo.

Edited by Apzo, 10 March 2006 - 11:15 AM.


#7 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 10 March 2006 - 11:05 AM

Attachments are not part of the POP3 protocol.
The mails are text encoded in the mailbox, and retrieved as text.

If you need to handle attachments, I've seen a base64 UDF around here that may suit your needs.
Why not ? It may be a great copy/paste party, but it shouldn't be difficult ;)

I'm thinking about some other protocols, such as SMTP and IRC :o
It's easy now to code net protocols with the new net and regexp functions :geek:
Apzo.

Yeah check out my sig for links to the base64 encoder/decoder. i also just updated my SMTP stuff in that same thread, so you might want to look at that as well. I modded the code from the beta Inet file for my smtp stuff.
C:\program Files\AutoIt3\beta\Include\Inet.au3

I also added sending email directly to the mx server in the example.

#8 Apzo

Apzo

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 10 March 2006 - 11:29 AM

Yeah check out my sig for links to the base64 encoder/decoder. i also just updated my SMTP stuff in that same thread, so you might want to look at that as well. I modded the code from the beta Inet file for my smtp stuff.
C:\program Files\AutoIt3\beta\Include\Inet.au3

I also added sending email directly to the mx server in the example.


Great job, once more :geek:

But attachments need mime decode :o
(I hope my boss didn't noticed my error)

A solution is to use Munpack; I'd prefer an UDF but I couldn't find some.

Apzo.

#9 theguy0000

theguy0000

    Benevolent Dictator

  • Active Members
  • PipPipPipPipPipPip
  • 3,750 posts

Posted 10 March 2006 - 04:06 PM

SMTP and IRC would be great!
The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

#10 =sinister=

=sinister=

    Whoo Custom Title!

  • Active Members
  • PipPipPipPipPipPip
  • 710 posts

Posted 18 September 2007 - 09:36 PM

Sorry to bring up such an old topic, But I really need help. It won't connect for me. I type in my info (using a gmail account) and I get an error. The @error is 9. What does that mean and how do I fix it?

#11 Apzo

Apzo

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 31 October 2007 - 10:17 AM

@ me to (also gmail), server: pop.gmail.com port: 995


Gmail doensn't use the pop3 protocol !
It's a web based one, like Hotmail.

Apzo.

#12 theguy0000

theguy0000

    Benevolent Dictator

  • Active Members
  • PipPipPipPipPipPip
  • 3,750 posts

Posted 31 October 2007 - 05:19 PM

Gmail doensn't use the pop3 protocol !
It's a web based one, like Hotmail.

Apzo.

you can still use pop3 if you want...and hotmail has pop3 servers too by the way...
The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

#13 mbkowns

mbkowns

    Wayfarer

  • Active Members
  • Pip
  • 77 posts

Posted 13 November 2007 - 03:58 AM

Anything new on SSL and pop3?

#14 Josbe

Josbe

    Infrequent ghost ☺

  • Active Members
  • PipPipPipPipPipPip
  • 1,585 posts

Posted 13 November 2007 - 06:20 AM

Gmail doensn't use the pop3 protocol !
It's a web based one, like Hotmail.

Apzo.

hmm..like Hotmail maybe not.
If you enable in the Settings(gmail), you can have POP and IMAP(recently added to gmail). Of course, IMAP is better. :P

#15 Apzo

Apzo

    Adventurer

  • Active Members
  • PipPip
  • 117 posts

Posted 13 November 2007 - 02:43 PM

Anything new on SSL and pop3?


http://mail.google.com/support/bin/answer.py?answer=13287

Pop enabled, yes, but SSL secured :P
Thus the IP port is not 110 but 995, and ssl encoded.

So far we don't have SSL funcs in AutoIt (HELP !), maybe stunnel would help.

BTW I'm still looking for Jabber doc and help : Jabber protocol (Gtalk) seems promising.
Any DLL coder in touch for it yet ?

Apzo.

#16 Alexandre Beloin

Alexandre Beloin

    Seeker

  • New Members
  • 1 posts

Posted 24 June 2008 - 02:48 AM

Maybe useful for other:

The function _Pop3Quit() send a QUIT to the server but doesn't run the function _Pop3Disconnect(), so you're never fully disconnected. A simple solution is to add _Pop3Disconnect() after _Pop3Quit()

Also _Pop3Disconnect() never reset $pop3_IsConnected to zero. So even if you use _Pop3Disconnect() you'll still be unable to connect again(Error: $pop3_error_already_connected). You need to add $pop3_IsConnected = 0 just before Return 0 in the function _Pop3Disconnect().

Func _pop3Disconnect()     If $pop3_IsConnected <> 0 Then         TCPCloseSocket ($pop3_socket)         TCPShutDown ()         $pop3_IsConnected = 0; Add this line to get a proper connection status         Return 0     Else         SetError($pop3_error_not_connected)         Return -1     EndIf EndFunc  ;==>_pop3Disconnect


#17 StAbb

StAbb

    Seeker

  • Active Members
  • 49 posts

Posted 14 October 2008 - 11:24 PM

So this UDF will not work with SSL right? No gmail, or yahoo? Also, what POP servers work with it, I have tried several and not had a lot of success.

Thanks!

Edited by StAbb, 14 October 2008 - 11:43 PM.


#18 flyingboz

flyingboz

    The Network Is All

  • Active Members
  • PipPipPipPipPipPip
  • 768 posts

Posted 27 October 2008 - 04:50 PM

So this UDF will not work with SSL right? No gmail, or yahoo? Also, what POP servers work with it, I have tried several and not had a lot of success.

Thanks!


Correct, it won't. Different reasons (unless you have a paid yahoo account).

Depending on what you need, you can check out the cdo mail methodology that's commonly used around here for sending mail, if you're trying to build a reader, don't have a lot of help for you.

I've written some code that at some time may be fleshed out enough involving blat and stunnel that gets me what I need for things like email logging, etc.
Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

#19 ptrex

ptrex

    Universalist

  • MVPs
  • 2,399 posts

Posted 27 October 2008 - 06:46 PM

@

This is all you need

See 2 nd post POP SSL

Regards

ptrex

#20 Tipulatoid

Tipulatoid

    Seeker

  • Active Members
  • 23 posts

Posted 28 October 2008 - 03:22 PM

I wrote (with great help from MrCreatoR) e-mail parser, which may be useful for someone.
It returns an Array where saved:
In the 1st line - Sender's name
In the 2nd line - Sender's address
In the 3rd line - Recipient name
In the 4th line - Recipient address
In the 5th line - Subject
In the 6th line - Charset
In the 7th line - Message body
In the 8th line - Attachment's name (if exists)
In the 9th line - Attachment's body (if exists)
In the next pairs of lines - names and bodies of the other attachments (if exist)
Plain Text         
#include <Array.au3> #include <_pop3.au3> ; Just example Global $MyPopServer = "pop.yandex.ru" Global $MyLogin = "delta2-greit" Global $MyPasswd = "will_not_say"   ; Connecting to POP3 _pop3Connect($MyPopServer, $MyLogin, $MyPasswd) If @error Then     MsgBox(16, "Error. Code " & @error, "Unable to connect to " & $MyPopServer)     Exit Else     ConsoleWrite("Connected to server pop3 " & $MyPopServer & @CR) EndIf ; Downloading letter #1 Local $retr = _Pop3Retr(1) If Not @error Then     $aParsedLetter = _ParseEmail ($retr); sends downloaded letter for parsing Else     ConsoleWrite("Retr commande failed" & @CR)     Exit EndIf ; Closing connection ConsoleWrite(_Pop3Quit() & @CRLF) ; End of the example     _ArrayDisplay ($aParsedLetter)   Func _ParseEmail ($sReadFile)     Dim $aLetter[1]     _AddToLetterArray (StringRegExp($sReadFile, '(?im)^From: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)     _AddToLetterArray (StringRegExp($sReadFile, '(?im)^To: +(.*)(?: |<)(?:.*?<|)(.*?)(?:>|)\r\n', 1), $aLetter)     _AddToLetterArray (StringRegExp($sReadFile, '(?im)^Subject: +(.*)\r\n', 1), $aLetter)     _AddToLetterArray (StringRegExp($sReadFile, '(?i) charset="?(.*?)(?:"|\r\n)', 1), $aLetter)     $aSplit = StringSplit ($sReadFile, @CRLF, 1)     $iFirstBoundaryString = _ArraySearch ($aSplit, "boundary=", 0, 0, 0, 1)     $iBoundary = $aSplit[$iFirstBoundaryString]     $iBoundary_startpos = StringInStr ($iBoundary, '"')     $iBoundary_endpos = StringInStr ($iBoundary, '"', 0, 2)     $boundary = StringMid ($iBoundary, $iBoundary_startpos+1, $iBoundary_endpos-$iBoundary_startpos-1)     $boundary1 = _ArraySearch ($aSplit, $boundary, $iFirstBoundaryString+1, 0, 1, 1)     $boundary2 = _ArraySearch ($aSplit, $boundary, $boundary1+1, 0, 1, 1)     $message = ""     $Write = False     For $i=$boundary1 To $boundary2-1         If $aSplit[$i] = "" Then $Write = True         If $Write = True Then $message &= $aSplit[$i] & @CRLF     Next     _AddToLetterArray ($message, $aLetter)       _AddToLetterArray (StringRegExp($sReadFile, '(?ims) filename="?(.*?)(?:"|\r).*?\n\r\n(.*?)\r\n^-+', 3), $aLetter)       Return $aLetter EndFunc; ==> _ParseEmail   Func _AddToLetterArray ($aContents, ByRef $afLetter)    If IsArray($aContents) Then         For $t = 0 to UBound ($aContents) - 1             _ArrayAdd ($afLetter, $aContents[$t])         Next     Else         _ArrayAdd ($afLetter, $aContents)     EndIf     Return $afLetter EndFunc;==>_AddToLetterArray

Any reaction will be highly appreciated.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users