Results 1 to 28 of 28

Thread: Here is a VB6 POP3 e-mail server...

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Here is a VB6 POP3 e-mail server...

    If anybody is curious about how to write a POP3 server in VB6, I'm making available my program Groupserver POP3. You can download the binaries or the source code here: http://serva.scieron.com/index.html

    Here's a screenshot:


    Enjoy!

    -Mike
    Last edited by half_eaten; Jan 25th, 2005 at 03:46 PM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    i haven't set up any accounts. I may move it to my w2k workststion.
    seems like hard to read code, not following standards. you should clean it up some it'd be easier to debug and follow.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    Quote Originally Posted by dglienna
    i haven't set up any accounts. I may move it to my w2k workststion.
    seems like hard to read code, not following standards. you should clean it up some it'd be easier to debug and follow.
    Erm yeah... hehe I'm pretty lazy. I'll go through and make it easier to follow.

    Thanks for checking it out though, when you really get a chance to test it out let me know what you think. I want to add an SMTP server too and make it a full-blown complete e-mail server.

    -Mike

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Here is a VB6 POP3 e-mail server...

    Quote Originally Posted by dglienna
    i haven't set up any accounts. I may move it to my w2k workststion.
    seems like hard to read code, not following standards. you should clean it up some it'd be easier to debug and follow.
    I get an error, 'Address in use' I might be running something else, i'll have a look,

    anyhows I'll get this moved over to the codebank, and i'll add a link to it in the
    Distributed Computing (multi-tier development)



  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    Quote Originally Posted by Pino
    I get an error, 'Address in use' I might be running something else, i'll have a look,

    anyhows I'll get this moved over to the codebank, and i'll add a link to it in the
    Distributed Computing (multi-tier development)


    Ahh.. yeah you have something else running on port 110. I'd better add an error routine for that!! See you guys are already helping me debug it!

    -Mike

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    you should use app.path also. I added it to the mail directory setting

    oh, and use freefile also (ff=freefile)

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    what's freefile?

    EDIT: the binaries and source code have been updated on my site to include the App.Path and it has an error handling routing in case port 110 is in use.

    -Mike
    Last edited by half_eaten; Jan 25th, 2005 at 04:44 PM.

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Here is a VB6 POP3 e-mail server...

    FreeFile is a function that returns the next available file number so as to ensure that the same number is not being used for more than one file. Here's an example of its use

    VB Code:
    1. Dim FileNum As Integer
    2.  
    3. ' Get the next available file number.
    4. FileNum = FreeFile
    5. ' Open a file using the file number
    6. Open "MYFILE.FIL" For Random As FileNum Len = RecLength

  9. #9
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Here is a VB6 POP3 e-mail server...

    half_eaten, would you like this thread moved to the CodeBank. Or maybe better would be to wait until you made whatever improvements you wanted to make and then post a new thread there.

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    I think I'll wait a little bit, people can can help me work bugs out..

    Thanks Martin for the freefile info!! I can't believe I didn't know that.

    -Mike

  11. #11

  12. #12

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    I am almost done with an ActiveX control version of the POP3 server engine in case anybody needs a POP3 server in their own programs. It's designed to be as simple as possible to use. Here some examples of code you would use to work with it. The control's name is SvrPOP3.

    SvrPOP3.InitServer - Starts server
    SvrPOP3.AddNewUser (UserName as string) - Adds a new user (duh)
    SvrPOP3.DeleteUser (UserName as string) - Delete a user
    SvrPOP3.ComposeMail (FromUser, ToUser, Subject, DateTime, MessageBody) - Put an e-mail in a user's account

    etc......



    I should be all done with that some time early tomorrow or later tonight. If anybody's interested, I'll post it here!

    -Mike

  13. #13

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    Okay people, here it is... the ActiveX version of the my POP3 server engine! If you need a POP3 server in your application, give this a shot... I attached the zip file of the OCX and a readme.txt file with instructions to this post!

    It will ask you to register. [Edited by MartinLiss]
    when you use the "Register" method, the registration name you should put in is "temp" and the registration code is "116101109112" the registration name is case-sensitive so make sure it's "temp" is in lowercase!!

    [Edited by MartinLiss]
    Enjoy!
    -Mike
    Attached Files Attached Files

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    Oh, I thought that you were going to include the source code, as well as the ocx. I don't know how many will download and actually try it.

    What's the point in a registration number that doesn't change?

  15. #15

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    who said it doesn't change? it depends on the registration name. i have a little program i wrote to generate it. don't worry its a decent registration routine... ill post the ocx code tonight too

    -Mike

  16. #16

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    Okay, here's the source code...

    -Mike
    Attached Files Attached Files

  17. #17
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Here is a VB6 POP3 e-mail server...

    Wow...nice.
    Cheers for posting your code here. Much appreciated.

    Once I have jigged your code a little I will see if it works.
    You failed to add "Option Explicit" at the top of your code.
    If you add this then you MUST declare a varible, ie:

    You have:
    Code:
    Private Sub Woof()
       MyMsg = "Growl"
       MsgBox MyMsg
    End Sub
    With Option Explicit you above code will error on the MyMsg = line.
    You would have to do:
    Code:
    Private Sub Woof()
    Dim MyMsg As String
       MyMsg = "Growl"
       MsgBox MyMsg
    End Sub
    You do this to avoid the following mistakes:
    Code:
    Private Sub Woof()
       MyMsg = "Growl"
       MyMsg = MyMsg & "Moose"
       MyMsg = NyMsg & "Fish"          'bad coding mistake here
       MsgBox MyMsg
    End Sub
    You have mispelt MyMsg as NyMsg. This could, and most likely to, cause your app to crash/not work.
    If you app does work, then top notch, I will be impressed you managed to iron out all bugs without option explicit

    Also, I think I may have worked out why it fails on Port 110.
    You are using winsock right. That's the sort of control that I would like to close gracefully, and shut it down properly. This way you know ports are closed correctly etc
    Your following code is, I would say, EVIL!
    Code:
    Private Sub itmExit_Click()
    res = MsgBox("If you close this program, the mail server will not function. Are you sure?", vbYesNo, "Postmaster")
    If res = vbNo Then Exit Sub
    End
    End Sub
    WHich you call from the Form_Unload event and from the menu exit event.
    It's the End command that is the problem here. As soon as your app sees this it terminates itself, and all it's objects. No Unload events get fired, no connects get closed. It can cause all sorts of wonderful and wierd things to happen. Some people like to use it as a last resort, but only after then have close things down 1st.
    That code should be:
    Code:
    Private Sub Form_Unload(Cancel As Integer)
       If MsgBox("If you close this program, the mail server will not function. Are you sure?", vbYesNo, "Postmaster") = vbYes Then
          'Code here to close winsock 
       Else
          Cancel = True
       End If
    End Sub
    
    Private Sub itmExit_Click()
       Unload Me
    End Sub
    That will unload your application gracefully, all objects closed properly blah blah blah.

    A few other small points:
    • Gotos, there's no need to use them in VB, they just cause unmanagable code (except error handlers)
    • Code indentation, makes it MUCH MUCH easier to follow blocks of code.
    • Varible naming, hungarian notation?
    • Using constants, or more modular level varibles
    • FreeFile thing that was mentioned above.


    Hahaha...Gotos that goto an actual "line number"
    I haven't seen that in about 10 years.
    Something you definately don't see every day

    If you need help with anything, or have any questions on anything we've mentioned, then just give us a shout.

    WOka

  18. #18
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Here is a VB6 POP3 e-mail server...

    I've just had a peek at your ocx code.
    Nice.

    One thing I did notice was you had 45 winsock controls on your form.
    You can dynamically create and destroy these at runtime. You can also use one winsock array to do everything, currently you have 1 array, and a seperate listening one, but this isn't a massive problem, just a little more code.
    Code:
    Option Explicit
    
    Private Sub POP_Close(Index As Integer)
       Unload POP(Index)
    End Sub
    
    Private Sub POP_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim lngNewIndex As Long
       If Index = 0 Then
           lngNewIndex = GetNextIndex
           Load POP(lngNewIndex)
           POP(lngNewIndex).Accept requestID
       End If
    End Sub
    
    Private Function GetNextIndex() AS Long
    Dim lngIndex As Long
    On Error Goto ErrHandler
       For lngIndex = 1 To POP.UBound
          lngNewIndex = POP(lngIndex).Index
       Next lngIndex
    ErrHandler:
       GetNextIndex = lngIndex
    Exit Function
    Something like that anyways.
    Does that make sense?

    When your form loads you get POP(0) to start listening for connections.

    WOka

  19. #19
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Here is a VB6 POP3 e-mail server...

    I hope you don't think I am having a go at you, or your code, here. I am merely pointing out ways to can improve it for your own benefit. You'll see the difference on how easy it is to add more functionality to it, with minimal code.

    One other point.
    Doing:
    Code:
    Private Sub ListMsgs(idx)
    Where you do not declare the parameter, or declare any varibles in functions, it means that it is a variant. These take up considerable more memory, plus are slower to deal with. Using the odd one in a place where it has a purpose is OK, but declaring all your varibles throughout your entire app maybe a little dodgy.

    Woof

  20. #20

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    No, I know you're not having a go at me.. I appreciate the pointers. I first started messing around for fun in GWBASIC when I was 6. I'm 20 now...

    About me using line number... yeah, I was raised on QuickBasic
    Still haven't lost all my old QB habits...

    When I was 13 I wrote a fully functional multi-node(16 nodes to be exact) BBS program in QuickBasic. I'm still proud of that, ended up with ~29,000 lines of QB code. It would show a static main screen showing what users are online and what they're doing while executing each node's events separately in the background, and if you wanted you could choose a node and it would show what they're seeing on their screen. Even had a multi-user chat room. Not trying to toot my own horn or anything, but I'm still more proud of that than anything else I've done really.

    I wish the damn floppy disk with the code didn't get full of data errors. Wish they had CD burners back then!

    Anyway more to the point, I'll go through and clean up my code and take a couple of your pointers.. I really threw it together in a hurry. I'm bad about that!!

    Btw, I do know about the variant thing... that falls under the category of me being lazy.
    THANKS for the tips!! It's appreciated.
    -Mike

  21. #21
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    QB didn't require line numbers, and I used them only as a last resort. Actually, I only used Line Labels, and that was sparingly, like for error routines. I used a couple of goto's also. I have a 6000 line program before I started getting out of memory errors. I quit development at that point.

  22. #22

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    Quote Originally Posted by dglienna
    QB didn't require line numbers, and I used them only as a last resort. Actually, I only used Line Labels, and that was sparingly, like for error routines. I used a couple of goto's also. I have a 6000 line program before I started getting out of memory errors. I quit development at that point.
    Yeah I didn't use them on every line, but I used them frequently say, when I had a line or two of code that was to accessed from multiple places in the code... I have some bad programming habits.

    And you think this POP3 server code is disorganized? You should've seen my BBS code!!

    I was going to add a few more features to that thing too, but when I got near 30,000 lines it told me it didn't have memory for any more code. LOL!

    -Mike

  23. #23
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    My re-write has almost 5000 lines, over 300 controls, and about 30 forms.
    It does a little bit more than the QB version.

  24. #24

  25. #25
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    I think it's just about done. Thanks. I've gotten help when I needed it.

  26. #26
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Here is a VB6 POP3 e-mail server...

    Quote Originally Posted by dglienna
    I think it's just about done. Thanks. I've gotten help when I needed it.
    My question was aimed at half_eaten, they said they were going to chamge their code.

    I wouldn't help you anyways Hehe

    Woof

  27. #27
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Here is a VB6 POP3 e-mail server...

    LOL - I thought you were having a good day, and felt like helping. You know I value your insight and ability.

  28. #28

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    56

    Re: Here is a VB6 POP3 e-mail server...

    Quote Originally Posted by Wokawidget
    My question was aimed at half_eaten, they said they were going to chamge their code.

    I wouldn't help you anyways Hehe

    Woof
    I haven't started yet... I'll have it done tonight and I'll post the new code... I was also going to clean up the code and make it easier to read. Thanks for the help!!

    I was going to have a go at an SMTP server soon also. That's going to be a little tougher!

    -Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width