I have an issue when the port of the smtp secure socket class is set to 465 and automatically changes to something like 51818 during sendmail method of that class. I placed my own method for sending emails in a class called “Errors”, which I instantiate when the app opens. The variable, which holds the instance of the smtp secure socket class, is a property of that class “Errors”. When I debug build my project, I see that the port is 465 until I step over the sendmail method.
Can somebody help?
That’s expected. The server that’s accepting the email on the other end has to create a separate socket on another port to handle your requests so it can continue listening on port 465 for other requests.
Then the mail server gets connected. But why can the mail server not handle my request then? That is to say, no matter if the port number is set to 465 or TLS, no mail can be sent.
There are a few issues that you could be having. First, are you getting any errors? If not, are you keeping the socket in scope long enough? The SMTPSocket sends asynchronously, so if the object goes out of scope, it’ll just stop sending.
I get no errors. The socket is a class property. The class instance is never destroyed while the app is running. What else could it be?
Are you sure that the provider supports sending email through that port? I’d try connecting via a telnet client and see if you get any direct errors.
Google Mail normally supports that port. Though the port changes to another value from 465 by the mail server, I noticed that the client app did not connect to the mail server at all. Networkinterface is shown Nil, Connected remains false. SSLConnection is false too. How can the port change when no connections was established? The username is correct, I tried both with and without @gmail.com ending. I also verified the password several times. I changed the order of the instructions too. I use the code from another of my apps, there it works well. The only difference is that no message dialog opens asking to send the mail.
It worked like this before: From a timer a method within another module was called, which instantiated a class that held the method to send the mail.
I deleted that class. I placed its method in the timer, from where everything starts. So the timer calls the method from the other module, and when its method is called, the mail is sent properly.