No connection on port 465

When running on localhost, my app can send email.

When deployed to Xojo Cloud, emails sent from my app are never received.

I would provide more debugging information but I don’t know how to get debugging information for deployed apps. If there is a way to do this, please let me know. With localhost, I use System.DebugLog and DebugViewer to get all the log info.

This is a continuation of this post.

Have you told the Xojo Cloud firewall to open that port for outbound connections? See here:

Damn, I feel like a dummy. Wasn’t aware of that. I will take care of that and let you know if it worked.

I added this to a button that is used to send email:

Dim fwp As New XojoCloud.FirewallPort(465, XojoCloud.FirewallPort.Direction.Outgoing) fwp.Open() if fwp.IsOpen then MsgBox "Port open" Session.GmailServer.Messages.Append msg Session.GmailServer.SendMail else MsgBox "Port not open" end

Port is open but still no emails received.

What do you get when you try to connect the the server? I suspect that you may be running into their 2-level authentication.

Not sure what you are asking but I do receive emails sent via localhost.

I wonder if the locally defined fwp goes out of scope and closes before the mail is sent?

I think you might be onto something there. How can I make it an object? I tried but couldn’t figure it out.

I tried leaving the WebContainer visible after the button press to send the email. Still no go.

Each application that connects to Gmail for send and receive has to have it’s own password. See this page:

Application-Specific Google Passwords

I set up 2-step verification on my gmail account. Still not working.

Do I need to subclass the SMTPSecureSocket? I will do that so I can use the events. Hopefully that will make sure it doesn’t go out of scope.

I still think it’s the firewall port. Make it a property of session.

That’s exactly what’s going on. Put the fwp property on the session and set it to nil in the MailSent event of the smtp socket.

Dumb question (I am such a novice): How do I put the fwp in properties for Session? I tried putting in XojoCloud.FirewallPort for target. This is why I was putting fwp in the button; I don’t know how to set up the property for fwp.

…I meant Type for Property in previous post.

  • Highlight the Session in the Navigator
  • In the menu bar click on Insert and then Property
  • In the Inspector give the new Property a Name and a Type of XojoCloud.FirewallPort (autocomplete does not work)

In your WebButton.Action Event, use the following code to instantiate the new FirewallPort Property for an outgoing port of 465 (assuming the Name is My_FirewallPort):

Session.My_FirewallPort = New XojoCloud.FirewallPort(465, XojoCloud.FirewallPort.Direction.Outgoing)

Well, it turns out there were multiple problems but it is working now thanks to everyone’s help.

First. I thought that both the firewall port and property had to be created in Session. My reasoning was that it might take a while for Xojo Cloud server to open the port so better open it early (although I realize it isn’t a good idea to open the port too early; not to mention possible timeout of port). Anyway, I couldn’t figure out how to make that work (can’t refer to the property from within Session. Again, novice here). So I used Frederick’s suggestion to put property in session and actually open the port in the button event just before sending.

Second. I turned on 2-step verification but didn’t read the instructions that Tom sent about the need to create an application-specific password. You can read about it here:

So, all I did by turning on 2-step verification and not creating the application-specific password was block all emails from localhost and XC. Once I figured out my mistake, it started working.

I couldn’t figure out how to use the MailSent event in an instance of SMTPSecureSocket named GmailServer. Error message is “Parameters are not compatible with this function Name”. Right now I am just using property GmailServer type SMTPSecureSocket in Session.

Again, thanks for everyone’s help. I really appreciate it.

If you are using AddHandler, the parameters of your method must be:

MyMailSent(socket as SecureSMTPSocket)

Otherwise you would not know which socket it came from if there were more than one.

Also, n the topic of firewall ports… They open synchronously, so by the time you call IsOpen, you should have your answer of whether or not it will be successful. As for timeouts, the object sends pings as long as you haven’t called Close and the object is still in existence. Once the framework hasn’t heard from that object in a while, the port gets closed.

This was very helpful. Thanks