General questions about how to send mails in functions #119
Replies: 6 comments
|
Server class is like QNetworkAccessManager you want only one in your application, unless you really want to send tons of emails at the same time, unlike QNAM each Server class represents a single connection to a server, so if you allocate 10 server classes that means 10 connections to your servers, so you likely want to keep one object around and just call send(mail) and they will be queued and processed in sequence. |
|
Also it's not thread safe, so you need one Server class per thread. |
|
Depending on the user that use my software, I guess most of my users will sent around 100 to 2000 mails. (It is a software for schools. So larger schools have maybe around 2000 students. As far as I know the largest school in the world has got 40.000 students.) Just an other question: Is there a way how to stop sending the mails if there is an error? I mean: If i sent 100 mails and the first one answers with an error (I think i must display a QMessage to the user with the error report) it will be bad if he might get 100 error reports. So how can I stop sending the mails and stop reporting the errors? |
|
You can either send one by one, and in case of an error you stop poping mails from your own queue. You should likely just auto server = std::make_shared(); make sure not to pass this as parent then. Since it's async you don't really need to worry about threads, unless you want a dedicated one or want to push |
|
Thank you so much. I will try. |
|
Maybe my case is too special, but what do you think about adding features like: |
Uh oh!
There was an error while loading. Please reload this page.
Hallo,
I have a larger project that should sent sometimes emails.
So my main Qt window has got several sub dialogs where I want to sent emails. Most of them contains functions that should sent several mails at once to different guys. So i want to run a loop in that functions for several (different) emails.
a) I don't know if I should do "auto server = new SimpleMail::Server;" only once in the main constructor of the program and use a global variable, or if i should do it in each constructor of every dialog or if i should do it in every function that sends mails.
b) I wonder if "auto server = new SimpleMail::Server;" needs a "delete server;" somewhere. Or if i better only use "SimpleMail::Server server" without "new".
c) Similar question as in a) just with "SimpleMail::ServerReply"
Thank you so much for your answer.
All reactions