When sending emails from a web app, the socket should be at the session or at the app level ?
If it is at the app level, what if two users want to send an email at the same time ?
Should I create a queue ?
I need to send a couple of mails in the background... no big numbers from 1 to 10 per hour, maybe less....
Anyway... the question is still valid... what happens if two users want to sen an email at the same time ?
Will the server allow two concurrent connections (from the same IP) ? Will both fail ?
Roman, my point with the process is this: you need to figure out where the socket is required in your application. I only need to send emails in one specific area of mine, so it makes sense that I will define the socket at the form (container) level. I am working on another app where it will be useful to do as Ralph says; session level. Mails can be sent from various processes in that application.
If you are dealing with low volumes, you don't have to worry too much about connections to the server. At least, I never encountered, nor have i seen here on the forum, any issue specifically related to this. Volume is the key factor that you will have to manage.
I do this at the application level. App starts and I create a global class that checks the database periodically for new mail and then creates the socket and sends the email.
It's not as efficient as one would hope. I should probably make it a separate console app that just runs in the background that does the exact same thing.