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.
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
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.
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.