Because http is a response protocol, if you want to send emails asynchronously, it must be implemented by the server itself, not http itself.
In terms of design, for those with ample server resources, a server can be used as a mail server and the interface can be exposed to the outside world to send emails asynchronously. Otherwise, you need to store the email and content to be sent (such as database, text file, redis, etc.), and then send it asynchronously through the following methods. For Windows series servers, you can write services and use system tasks to implement them simply. For Linux series servers, this can be achieved through corntiming, daemon processes, etc.
Put a piece of data into the message table (including sendee, sending status, sending problem, sending type), create a task, scan the message table regularly, find unsent messages, send the message, and modify the status of the message table
Because http is a response protocol, if you want to send emails asynchronously, it must be implemented by the server itself, not http itself.
In terms of design, for those with ample server resources, a server can be used as a mail server and the interface can be exposed to the outside world to send emails asynchronously.
Otherwise, you need to store the email and content to be sent (such as database, text file, redis, etc.), and then send it asynchronously through the following methods.
For Windows series servers, you can write services and use system tasks to implement them simply.
For Linux series servers, this can be achieved through
corn
timing, daemon processes, etc.Put a piece of data into the message table (including sendee, sending status, sending problem, sending type), create a task, scan the message table regularly, find unsent messages, send the message, and modify the status of the message table
Personally, I feel it’s a bit too complicated. Isn’t it possible to just open the thread and adjust it asynchronously?