XOJO Mail: Port and Security?

  1. 2 weeks ago

    James W

    Oct 2 Tangent, Oregon, USA
    Edited 2 weeks ago

    Greetings - I'm writing a security application. It monitors certain hardware and maintains a log of the readings. Every midnight, it needs to email a copy of the previous 24 hour log to the department head. I am using XOJO 2017R1. It is a VERY large building that I cannot reveal at this point; I suspect that they have their own mail sever. I know that I need to find out the server name is, what port number it uses and what the security requirements are.

    M y first question has to do with port number and privileges. It appears that ports 25, 110, or 587 are the ones most likely to be needed. Under SocketCore.LastErrorCode, the LR says: “you can only bind to ports less than 1024 if you have “root” privileges. A normal “Admin” user does not have root privileges.” But, under SocketCore.Port, it says: “On most operating systems, attempting to bind to a port less than 1024 causes a Error event to fire with an error number 107 unless the application is running with administrative permissions.” Which one is it, and how do insure that the application is running under the correct privileges (Mac for testing and Win for use target)?

    The second question has to do with SMTPSecureSocket. This appears to be needed with Port 587. The first hurdle, here, is that I do not understand the statement: “If you use a constructor in a subclass of a SMTPSecureSocket, you must call the Super class's constructor in your subclass's constructor. The subclass will not work unless this is done.” The second hurdle is actually how to use it and how to deal with SSL Certificate? Is this something that has to be acquired? If so, where? Or, is there some sort of blanket certificate available for XOJO apps? Finally, where can I see an example using SMTPSecureSocket? That would really help!

    Thanks
    Jim Wagner
    Oregon Research Electronics

  2. Andrew L

    Oct 2 San Francisco, CA, USA

    You do not need special privileges to connect to a port, regardless of the port number. "Binding" to a port (AKA "listening") is something that happens when your socket is accepting inbound connections. But your app wants to initiate an outbound connection to a mail server (and it's the server that has to worry about binding and permissions.)

    @James W The second question has to do with SMTPSecureSocket. This appears to be needed with Port 587. The first hurdle, here, is that I do not understand the statement: “If you use a constructor in a subclass of a SMTPSecureSocket, you must call the Super class's constructor in your subclass's constructor. The subclass will not work unless this is done.”

    Constructor methods are a special method of a class that gets called automatically when you create an instance of the class. All Xojo socket classes do some necessary initialization work in their Constructor methods. If you override the Constructor in a subclass then you must make sure to call Super.Constructor() so that this initialization can be done.

    Sub Constructor()
         Super.Constructor() // execute the superclass Constructor
         // your initialization code here
    End Sub

    If you aren't overriding the Constructor then you don't need to worry about this.

  3. James W

    Oct 3 Tangent, Oregon, USA

    Thanks, Andrew. that helps a lot. Is there somewhere I can find example code for using SMTPSecureSocket?

    Jim

    James Wagner
    Oregon Research Electronics

  4. Jean-Yves P

    Oct 3 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    Xojo/Example Projects/Communication/Internet/Email/SMTPSecureSocketExample.xojo_binary_project

  5. James W

    Oct 3 Tangent, Oregon, USA

    Missed that. Thanks.

    Maybe the example indicates, but will ask ahead, here. Can an SMTPSecureSocket be used in situations NOT requiring TLS/SSL? Or, do I need to have both the secure and insecure sockets available?

    Jim Wagner
    Oregon Research Electronics

  6. Beatrix W

    Oct 3 Pre-Release Testers, Third Party Store Europe (Germany)

    See https://docs.xojo.com/SSLSocket.Secure .

  7. James W

    Oct 3 Tangent, Oregon, USA

    Thanks Beatrix - I had not gotten that far in the documentation, yet.

    Jim

  8. Jean-Yves P

    Oct 3 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    I have had problems with trying to connect an smtpsecuresocket to a non-ssl smtp server.
    I had to make a test, instanciating a smtpsocket or smtpsecuresocket myself depending on the secure property.
    it may be a problem from the starttls that you cannot clear.

  9. James W

    Oct 3 Tangent, Oregon, USA

    Maybe there is something "left over" from that unsuccessful connection attempt? But, interesting. I was wondering about having to do exactly that.

    Jim

  10. last week

    Rob H

    Oct 7 Canada

    @James W - did you try the example in the Examples folder that @Jean-YvesPochez mentioned? the SendDemoWindow has complete code that works really well. You can just drag the MailSocket control into your project, configure it and run it. It even gives you errors to help you troubleshoot.

or Sign Up to reply!