Email is not sent even if firewall port is opened on Xojo cloud

In web application, when run locally mail is sent properly, but when I upload it on Xojo Cloud the email is not sent, I have opened the firewall port as well but mail is still not being sent.
What might be the problem?

Thanks

[quote=353420:@devyani gaikwad]In web application, when run locally mail is sent properly, but when I upload it on Xojo Cloud the email is not sent, I have opened the firewall port as well but mail is still not being sent.
What might be the problem?

Thanks[/quote]
Please show the code you are using to open the firewall.

FOr port, I retrieve port from Database and in database it is 587.


    
    Dim fwp As New XojoCloud.FirewallPort(587,  _
    XojoCloud.FirewallPort.Direction.Outgoing)
    fwp.Open
    If fwp.isOpen Then
    
      Dim mail As EmailMessage
      'Dim file As EmailAttachment
      Mailobject = new  MailSocket
      'AddHandler MailObject.MailSentFromObject, AddressOf EmailSentFromMailObject
      MailObject.Address =server
      Mailobject.ConnectionType = SSLSocket.TLSv12
      MailObject.Port =port
      MailObject.Username=emailid
      MailObject.Password =pwd
      MailObject.Connect
      mail = New EmailMessage
      mail.FromAddress = emailid
      mail.Subject = ""test"
      Receiver=txtEmailID.text
 
      Dim My_HTTPSocket As New HTTPSocket
      My_HTTPSocket.Yield = True
      
      mail.BodyPlainText = "test"
      mail.addRecipient(Receiver)
      Mailobject.Messages.Append(mail)
      Mailobject.SendMail

    Else
      'MsgBox("Firewall port is .closed")
    End If
 

My guess is that the email has not yet been sent when the method finishes running so the firewall port gets closed during sending. I would try adding a socket object or property that stays in scope long enough for the mail to send. This example will help:

Xojo 2017 Release 2.1/Example Projects/Communication/Internet/EmailSSLExample

Jason is correct. You have two problems here.

  1. Sending email is Asynchronous. When Sendmail is called, it starts a background process and continues the current method. When your MsilObject goes out of scope, sending stops.
  2. Because of #1, you need to also hold that firewall object somewhere… because once it goes out of scope it automatically closes the port it was holding open for you.

I tried keeping the mail object in scope, but it didnt work.
So i tried MBS CURL plugin for that, and now it works.
Email is sent now

Thank you.