CN112134790A - Priority-based mail sending method, device, equipment and storage medium - Google Patents
Priority-based mail sending method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN112134790A CN112134790A CN202011040403.0A CN202011040403A CN112134790A CN 112134790 A CN112134790 A CN 112134790A CN 202011040403 A CN202011040403 A CN 202011040403A CN 112134790 A CN112134790 A CN 112134790A
- Authority
- CN
- China
- Prior art keywords
- sending
- priority
- request
- mails
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 46
- 238000004458 analytical method Methods 0.000 claims abstract description 17
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 12
- 238000012163 sequencing technique Methods 0.000 claims abstract description 5
- 230000005540 biological transmission Effects 0.000 claims description 93
- 238000012544 monitoring process Methods 0.000 claims description 26
- 238000004590 computer program Methods 0.000 claims description 11
- 230000003139 buffering effect Effects 0.000 claims description 6
- 238000004364 calculation method Methods 0.000 claims description 3
- 230000008569 process Effects 0.000 description 12
- 230000003203 everyday effect Effects 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 230000032683 aging Effects 0.000 description 6
- 241000700605 Viruses Species 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 101001094649 Homo sapiens Popeye domain-containing protein 3 Proteins 0.000 description 4
- 101000608234 Homo sapiens Pyrin domain-containing protein 5 Proteins 0.000 description 4
- 101000578693 Homo sapiens Target of rapamycin complex subunit LST8 Proteins 0.000 description 4
- 102100027802 Target of rapamycin complex subunit LST8 Human genes 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 108010041420 microbial alkaline proteinase inhibitor Proteins 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 206010000210 abortion Diseases 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000007257 malfunction Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/21—Monitoring or handling of messages
- H04L51/214—Monitoring or handling of messages using selective forwarding
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/21—Monitoring or handling of messages
- H04L51/23—Reliability checks, e.g. acknowledgments or fault reporting
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/42—Mailbox-related aspects, e.g. synchronisation of mailboxes
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses a priority-based mail sending method, which comprises the following steps: acquiring the sending success time and the reading receipt time of various mails within a preset time period; calculating the priority of each type of mail according to the sending success time, the reading receipt time and a preset priority algorithm; acquiring mails to be sent in a current time period, and generating a mail sending request of each mail according to the mails to be sent, wherein the mails to be sent comprise at least one mail, and the mail sending request comprises a priority corresponding to the mail; caching the mail sending requests in a request queue, and sequencing the mail sending requests in the request queue according to the priority of the mail sending requests; and reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests, and sending mails according to the mail data obtained after analysis. The problem of sending the mails can be effectively solved.
Description
Technical Field
The embodiment of the invention relates to the technical field of communication, in particular to a priority-based mail sending method, device, equipment and storage medium.
Background
When sending mails, the mail function of the existing mailbox randomly orders and sends all the mails to be sent or orders the mails according to the generation time of the mail task, so that the urgency degree of the mail task cannot be effectively embodied. Under the condition that system resources are sufficient and the quantity of mails to be sent is not large, the mails can be sent within tolerable time, and the contradiction is not obvious; once the mail tasks are overstocked due to system maintenance or version-off service or time consumption of some mail tasks, some mails with high requirement on timeliness cannot be sent out in time.
Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a method, an apparatus, a device and a storage medium for sending a mail based on priority, which can effectively solve the problem of sending the mail.
In order to achieve the above object, an embodiment of the present invention provides a priority-based email sending method, including:
acquiring the sending success time and the reading receipt time of various mails within a preset time period;
calculating the priority of each type of mail according to the sending success time, the reading receipt time and a preset priority algorithm;
acquiring mails to be sent in a current time period, and generating a mail sending request of each mail according to the mails to be sent, wherein the mails to be sent comprise at least one mail, and the mail sending request comprises a priority corresponding to the mail;
caching the mail sending requests in a request queue, and sequencing the mail sending requests in the request queue according to the priority of the mail sending requests;
and reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests, and sending mails according to the mail data obtained after analysis.
Further, before the acquiring the sending success time and the reading receipt time of the multiple types of mails in the preset time period, the method includes:
monitoring the plurality of types of mails;
and establishing a timing task to record the sending success time and the reading receipt time of various types of mails.
Further, the caching the mail sending request in a request queue, and the sorting the mail sending requests in the request queue according to the priority of the mail sending request includes:
sorting the mail sending requests in the request queue according to the priority and the cache time of the mail sending requests; wherein,
for the mail sending requests with different priorities, the mail sending request with low priority is ranked in front of the mail sending request with high priority;
for the mail sending requests with the same priority, the mail sending request with the early cache time is ranked before the mail sending request with the later cache time.
Further, the reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests, and sending the mails according to the mail data obtained after analysis includes:
creating a mail sending thread;
judging whether the position of the last read mail sending request is the last position of the request queue or not according to the mail sending thread, if so, returning to the first position of the request queue to read the mail sending request, and if not, starting to read the mail sending request from the next position of the last read position;
and analyzing the mail sending request based on the mail sending thread, and calling an application programming interface of a mail server to send the mail according to the mail data obtained after analysis.
Further, the reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests, and after sending the mails according to the mail data obtained after analysis, the method includes:
judging whether the mail is successfully sent or not through the mail sending thread;
if the transmission is successful, deleting the mail transmission request corresponding to the mail from the request queue;
if the transmission fails, deleting the mail transmission request corresponding to the mail from the request queue, and then re-caching the mail transmission request in the request queue and sequencing.
Further, the method further comprises:
when sending the mails in the next time period, acquiring the unsent mails in the current time period and the newly added sent mails in the next time period;
and determining the priority of the newly added sent mails, and reordering the sending requests corresponding to the newly added mails and the unsent mails in the request queue according to the priority.
Further, the method further comprises:
and caching the mail sending request and at least one mail in the mail sending request and the priority corresponding to the mail into a block chain.
In order to achieve the above object, an embodiment of the present invention provides a priority-based mail sending apparatus, including:
the acquisition module is used for acquiring the sending success time and the reading receipt time of various mails within a preset time period;
the calculation module is used for calculating the priority of each type of mail according to the sending success time, the reading receipt time and a preset priority algorithm;
the generating module is used for acquiring mails to be sent in the current time period and generating a mail sending request of each mail according to the mails to be sent, wherein the mails to be sent comprise at least one mail, and the mail sending request comprises a priority corresponding to the mail;
the sorting module is used for caching the mail sending request in a request queue and sorting the mail sending requests in the request queue according to the priority of the mail sending request;
and the analysis sending module is used for reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests and sending mails according to the mail data obtained after analysis.
Further, the ranking module is further to:
sorting the mail sending requests in the request queue according to the priority and the cache time of the mail sending requests: wherein,
for the mail sending requests with different priorities, the mail sending request with low priority is ranked in front of the mail sending request with high priority;
for the mail sending requests with the same priority, the mail sending request with the early cache time is ranked before the mail sending request with the later cache time.
To achieve the above object, an embodiment of the present invention provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the computer program, when executed by the processor, implements the steps of the priority-based mail sending method as described above.
To achieve the above object, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, the computer program being executable by at least one processor to cause the at least one processor to execute the steps of the priority-based mail transmission method as described above.
According to the priority-based mail sending method, the priority-based mail sending device, the priority-based mail sending equipment and the priority-based mail storage medium, the priority of the mail is determined according to the sending success time and the reading receipt time of the mail, then the mail is cached in the queue, the mail sending request is read from the caching queue according to the priority, and the mail is sent, so that the important mail can be timely and reliably sent. The method and the system effectively reflect the actual emergency degree of the mail according to the attention degree of the receiver to the mail, thereby achieving the purpose that important mails can be sent out in time under the backlog condition of the mail and solving the problem of timeliness to a certain degree.
Drawings
Fig. 1 is a flowchart of a first embodiment of a priority-based email sending method according to the present invention.
Fig. 2 is a flowchart of step S110 according to an embodiment of the present invention.
Fig. 3 is a flowchart of step S160 according to an embodiment of the present invention.
Fig. 4 is a flowchart of step S180 according to an embodiment of the present invention.
Fig. 5 is a flowchart of step S190 according to an embodiment of the present invention.
Fig. 6 is a schematic diagram of program modules of a second priority-based mail sending apparatus according to an embodiment of the present invention.
Fig. 7 is a schematic diagram of a hardware structure of a third embodiment of the computer apparatus according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Referring to fig. 1, a flowchart of steps of a priority-based mail sending method according to a first embodiment of the present invention is shown. It is to be understood that the flow charts in the embodiments of the present method are not intended to limit the order in which the steps are performed. The following description is made by way of example with the computer device 2 as the execution subject. The details are as follows.
And step S100, acquiring the sending success time and the reading receipt time of various mails within a preset time period.
Specifically, the sending success time and the reading receipt time after each mail is sent within the preset time period are monitored and recorded. And a timing task is established in advance, and the sending success time and the reading receipt time of the mails sent every day are recorded every day. And monitoring the progress of the mail before acquiring the successful sending time and the receipt reading time of the mail, wherein the monitoring of the progress of the mail is divided into mail receiving monitoring and mail sending monitoring. Mail reception monitoring: when a user receives a mail, the mail received by the user is intercepted in advance for virus checking and killing, the time of successful sending is recorded, and a monitoring report is generated. Mail reception monitoring does not require any modification to the user's mail program, monitoring the time the user opens the mail for reading, or the time from opening the mail to sending a reading receipt. Mail reception monitoring only supports the POP3 protocol and cannot monitor IMAP, MAPI and mail received via WEB. The email type is actually an email account type, and this is related to the mailing protocol supported by the corresponding email server. For example, the QQ mailbox supports the account types of POP3/IMAP/SMTP/Exchange and the like.
The mail sending monitoring also includes the following functions: all mail clients using the SMTP protocol are supported. And virus scanning is carried out on the sent mails, the mails are prohibited from being sent if the mails are found to be infected, and the mails are permitted to be sent after the users clear the viruses, so that the viruses are prevented from being spread. The mail transmission monitoring supports only the SMTP protocol and does not support MAPI and mail transmitted through the Web.
Illustratively, referring to fig. 2, before the step S100, a step S110 is included:
step S111, monitoring the various types of mails.
Specifically, through asynchronous tasks, business or life related mails received by the mails are regularly monitored every day.
Step S112 sets up a timing task to record the transmission success time and reading receipt time of the plurality of types of mails.
Specifically, the time of success of sending mail and the time of collection of reading receipt are set every day so as to facilitate updating of the priority.
And step S120, calculating the priority of each type of mail according to the sending success time, the reading receipt time and a preset priority algorithm.
Specifically, the processing timeliness of each mail is obtained according to the sending time and the reading receipt time and is used as key basic data for calculating the priority; and calculating the priority of each mail type according to a priority algorithm. The priority algorithm is calculated as follows:
W(A)=(P(A))/(P(A)+P(B)+…+P(N));
P(A)=(V1+V2+…Vn)/n;
T=T2-T1;
wherein A, B, N is the code number of the mail; w (A) represents: the priority of the mail; p (A) represents: e, mail average treatment aging; v represents: e, mail single treatment aging; t1 denotes: a single-time transmission success time representation of the mail; t2: reading the receipt time after the mail is sent once; t represents the treatment aging of the mail; n is a positive integer.
For example, the priority of the mail can also be divided according to the importance and the urgency of the mail content, and the more important mail has higher priority and the more urgent mail has higher priority. For example, the priority of the mail with the down server is set to be high, the priority of the mail with the physical machine CPU load exceeding 90% is set to be medium, and the priority of the mail with the physical machine CPU load exceeding 85% is set to be low.
Illustratively, an asynchronous task is established, the priority of the mail is refreshed once every day based on the latest data, the sending mechanism of the mail is dynamically adjusted, after the timeliness of a certain type of mail changes, the priority can be automatically adjusted step by step through sample accumulation, and the final accuracy of the priority is guaranteed. The asynchronous task is established as follows: some task processes can be established in advance in a local server or other servers or even a server cluster to process heavy services, the number of the task processes can be increased, for example, 10 times of the cpu, and then data is asynchronously sent to the task processes by using the AsyncTcpConnection to be processed asynchronously, so that a processing result is obtained asynchronously.
Step S140, obtaining mails to be sent in the current time period, and generating a mail sending request of each mail according to the mails to be sent, wherein the mails to be sent comprise at least one mail, and the mail sending request comprises a priority corresponding to the mail.
Specifically, a mail sending request is generated according to the mail to be sent in the current time period and the sending operation of the user to the mail, and the mail sending request may include one or more of the following information: request identification, receiver address, sender address, mail subject, mail content, priority of mail; the priority of the mail may be: high, medium or low, set according to the value of the priority of the mail, for example high above a certain value.
Step S160, buffering the mail sending requests in a request queue, and sorting the mail sending requests in the request queue according to the priority of the mail sending requests.
Specifically, when the mail is transmitted according to the mail transmission request, the transmission order is determined according to the latest priority, and the transmission is preferentially performed with a low priority value. The latest priority can be refreshed once a day based on the latest received mail and the transmission success time and reading receipt time of the mail by establishing an asynchronous task.
Exemplarily, referring to fig. 3, the step S160 specifically includes:
step S161, sorting the mail sending requests in the request queue according to the priority and the cache time of the mail sending requests.
Step S162, wherein, for the mail sending requests with different priorities, the mail sending request with low priority is ranked before the mail sending request with high priority.
In step S163, for mail transmission requests of the same priority, a mail transmission request of an early buffer time is ranked ahead of a mail transmission request of a later buffer time.
Specifically, examples are as follows: for example, there are 5 mail sending requests in the request queue, which are: a No. 1 mail transmission request (high priority), a No. 2 mail transmission request (high priority), a No. 3 mail transmission request (medium priority), a No. 4 mail transmission request (medium priority), and a No. 5 mail transmission request (low priority).
When polling the request queue for the first time, reading the No. 5 mail sending request and sending the mail, and reading the No. 4 mail sending request and sending the mail; before reading the No. 1 mail sending request, judging that the mail corresponding to the No. 5 mail sending request is successfully sent, and deleting the No. 5 mail sending request from the request queue; then reading the No. 1 mail sending request and sending the mail; judging that the transmission of the No. 4 mail transmission request has failed before reading the No. 2 mail transmission request, and therefore deleting the No. 4 mail transmission request from the request queue, re-buffering the No. 4 mail transmission request in the request queue, and since the priority of the re-buffered No. 4 mail transmission request is still medium, the re-buffered No. 4 mail transmission request is queued before the No. 2 mail transmission request, and then comparing the buffering time of the re-buffered No. 4 mail transmission request with that of the No. 3 mail transmission request of the same priority, the buffering time of the re-buffered No. 4 mail transmission request is later than that of the No. 3 mail transmission request, and therefore, sorting the re-buffered No. 4 mail transmission request after the No. 3 mail transmission request, the re-buffered No. 4 mail transmission request can be read and transmitted at the time of the second polling request queue, thus improving the reliability of mail transmission.
And step S180, reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests, and sending the mails according to the mail data obtained after analysis.
Specifically, the priority of the mail sending request is read, the mails are sent according to the priority order, and if the priorities are the same, the factors such as the cache time and the like can be referred to.
Exemplarily, referring to fig. 4, the step S180 specifically includes:
in step S181, a mail transmission thread is created.
Specifically, a mail sending thread is created to control sending of a mail, one thread refers to a single-order control flow in a process, a plurality of threads can be concurrently sent in one process, each thread executes different tasks in parallel, and sending of the mail is a single-thread task.
Step S182, judging whether the position of the last read mail sending request is the last bit of the request queue according to the mail sending thread, if so, returning to the first bit of the request queue to read the mail sending request, and if not, starting to read the mail sending request from the next bit of the last read position.
Specifically, the read mail sending request is judged according to the position of the last mail sending request in the request queue, and if the reading in the current request queue is completed, the newly added mail sending request is read.
And step S183, analyzing the mail sending request based on the mail sending thread, and calling an application programming interface of the mail server to send the mail according to the mail data obtained after analysis.
Specifically, the email sending request is analyzed to obtain the email address of the recipient, and then the email is sent through an application Programming interface (api) of the email server.
Exemplarily, referring to fig. 5, after the step S180, a step S190 is included:
and step S191, judging whether the mail is successfully sent or not through the mail sending thread.
Step S192, if the transmission is successful, the mail transmission request corresponding to the mail is deleted from the request queue.
Step S193, if the transmission fails, deleting the mail transmission request corresponding to the mail from the request queue, and then re-buffering the mail transmission request in the request queue and performing sorting.
Specifically, when the mail is sent, a mail monitoring process running in a background; the mail monitoring process monitors the operation condition of the mail sending thread, and restarts the mail sending thread if the abnormal operation of the mail sending thread is detected; the mail monitoring process also regularly backs up the data in the request queue, and if the loss of the data in the request queue is detected, the request queue is automatically restored according to the backed-up data; wherein, the mail sending thread runs abnormally, such as: the mail sending thread automatically destroys or aborts (malfunctions) for some reason or error.
Illustratively, the method further comprises:
when sending the mails in the next time period, acquiring the unsent mails in the current time period and the newly added sent mails in the next time period; and determining the priority of the newly added sent mails, and reordering the sending requests corresponding to the newly added mails and the unsent mails in the request queue according to the priority.
Specifically, when sending the mail in the next time period, the sending requests corresponding to the mails which are not sent in the current time period and the newly added mails in the next time period are reordered in the request queue, so that the urgent mails in the next time period can be sent preferentially.
Illustratively, the method further comprises:
and caching the mail sending request and at least one mail in the mail sending request and the priority corresponding to the mail into a block chain.
Specifically, uploading a mail sending request to the blockchain can ensure the safety and the fair transparency of the mail sending request to the user. The user equipment can download the mail sending request from the blockchain so as to check whether the mail and the corresponding priority of the mail are tampered. The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Example two
Referring to fig. 6, a program module diagram of a second priority-based mail sending apparatus according to an embodiment of the invention is shown. In this embodiment, the priority-based mail sending apparatus 20 may include or be divided into one or more program modules, which are stored in a storage medium and executed by one or more processors, to accomplish the present invention and implement the above-described priority-based mail sending method. The program module referred to in the embodiments of the present invention refers to a series of computer program instruction segments capable of performing specific functions, and is more suitable than the program itself for describing the execution process of the priority-based mail transmission apparatus 20 in the storage medium. The following description will specifically describe the functions of the program modules of the present embodiment:
the obtaining module 200 is configured to obtain sending success times and reading receipt times of multiple types of mails within a preset time period.
Specifically, the sending success time and the reading receipt time after each mail is sent within the preset time period are monitored and recorded. And a timing task is established in advance, and the sending success time and the reading receipt time of the mails sent every day are recorded every day. And monitoring the progress of the mail before acquiring the successful sending time and the receipt reading time of the mail, wherein the monitoring of the progress of the mail is divided into mail receiving monitoring and mail sending monitoring. Mail reception monitoring: when a user receives a mail, the mail received by the user is intercepted in advance for virus checking and killing, the time of successful sending is recorded, and a monitoring report is generated. Mail reception monitoring does not require any modification to the user's mail program, monitoring the time the user opens the mail for reading, or the time from opening the mail to sending a reading receipt. Mail reception monitoring only supports the POP3 protocol and cannot monitor IMAP, MAPI and mail received via WEB. The email type is actually the account type of the email, and this is related to the mailing protocol supported by the corresponding email server. For example, the QQ mailbox supports the account types of POP3/IMAP/SMTP/Exchange and the like.
A calculating module 202, configured to calculate a priority of each type of email according to the sending success time, the reading receipt time, and a preset priority algorithm.
Specifically, the processing timeliness of each mail is obtained according to the sending time and the reading receipt time and is used as key basic data for calculating the priority; and calculating the priority of each mail type according to a priority algorithm. The priority algorithm is calculated as follows:
W(A)=(P(A))/(P(A)+P(B)+…+P(N));
P(A)=(V1+V2+…Vn)/n;
T=T2-T1;
wherein A, B, N is the code number of the mail; w (A) represents: the priority of the mail; p (A) represents: e, mail average treatment aging; v represents: e, mail single treatment aging; t1 denotes: a single-time transmission success time representation of the mail; t2: reading the receipt time after the mail is sent once; t represents the treatment aging of the mail; n is a positive integer.
The generating module 204 is configured to obtain a to-be-sent mail in a current time period, and generate a mail sending request of each mail according to the to-be-sent mail, where the to-be-sent mail includes at least one mail, and the mail sending request includes a priority corresponding to the mail.
Specifically, a mail sending request is generated according to the mail to be sent in the current time period and the sending operation of the user to the mail, and the mail sending request may include one or more of the following information: request identification, receiver address, sender address, mail subject, mail content, priority of mail; the priority of the mail may be: high, medium or low, set according to the value of the priority of the mail, for example high above a certain value.
A sorting module 206, configured to cache the mail sending request in a request queue, and sort the mail sending requests in the request queue according to the priority of the mail sending request.
Specifically, when the mail is transmitted according to the mail transmission request, the transmission order is determined according to the latest priority, and the transmission is preferentially performed with a low priority value. The latest priority can be refreshed once a day based on the latest received mail and the transmission success time and reading receipt time of the mail by establishing an asynchronous task.
Illustratively, the sorting module 206 is specifically configured to:
and sorting the mail sending requests in the request queue according to the priority and the caching time of the mail sending requests.
Wherein, for the mail sending requests with different priorities, the mail sending request with low priority is ranked before the mail sending request with high priority.
For the mail sending requests with the same priority, the mail sending request with the early cache time is ranked before the mail sending request with the later cache time.
Specifically, examples are as follows: for example, there are 5 mail sending requests in the request queue, which are: a No. 1 mail transmission request (high priority), a No. 2 mail transmission request (high priority), a No. 3 mail transmission request (medium priority), a No. 4 mail transmission request (medium priority), and a No. 5 mail transmission request (low priority).
When polling the request queue for the first time, reading the No. 5 mail sending request and sending the mail, and reading the No. 4 mail sending request and sending the mail; before reading the No. 1 mail sending request, judging that the mail corresponding to the No. 5 mail sending request is successfully sent, and deleting the No. 5 mail sending request from the request queue; then reading the No. 1 mail sending request and sending the mail; judging that the transmission of the No. 4 mail transmission request has failed before reading the No. 2 mail transmission request, and therefore deleting the No. 4 mail transmission request from the request queue, re-buffering the No. 4 mail transmission request in the request queue, and since the priority of the re-buffered No. 4 mail transmission request is still medium, the re-buffered No. 4 mail transmission request is queued before the No. 2 mail transmission request, and then comparing the buffering time of the re-buffered No. 4 mail transmission request with that of the No. 3 mail transmission request of the same priority, the buffering time of the re-buffered No. 4 mail transmission request is later than that of the No. 3 mail transmission request, and therefore, sorting the re-buffered No. 4 mail transmission request after the No. 3 mail transmission request, the re-buffered No. 4 mail transmission request can be read and transmitted at the time of the second polling request queue, thus improving the reliability of mail transmission.
And the analysis sending module 208 is configured to sequentially read the mail sending requests from the request queue, analyze the mail sending requests, and send mails according to the mail data obtained after analysis.
Specifically, the priority of the mail sending request is read, the mails are sent according to the priority order, and if the priorities are the same, the factors such as the cache time and the like can be referred to.
Illustratively, the parsing and sending module 208 is specifically configured to:
a mail sending thread is created.
Specifically, a mail sending thread is created to control sending of a mail, one thread refers to a single-order control flow in a process, a plurality of threads can be concurrently sent in one process, each thread executes different tasks in parallel, and sending of the mail is a single-thread task.
And judging whether the position of the last read mail sending request is the last bit of the request queue or not according to the mail sending thread, if so, returning to the first bit of the request queue to read the mail sending request, and if not, starting to read the mail sending request from the next bit of the last read position.
Specifically, the read mail sending request is judged according to the position of the last mail sending request in the request queue, and if the reading in the current request queue is completed, the newly added mail sending request is read.
And analyzing the mail sending request based on the mail sending thread, and calling an application programming interface of a mail server to send the mail according to the mail data obtained after analysis.
Specifically, the email sending request is analyzed to obtain the email address of the recipient, and then the email is sent through an application Programming interface (api) of the email server.
EXAMPLE III
Fig. 7 is a schematic diagram of a hardware architecture of a computer device according to a third embodiment of the present invention. In the present embodiment, the computer device 2 is a device capable of automatically performing numerical calculation and/or information processing in accordance with a preset or stored instruction. The computer device 2 may be a rack server, a blade server, a tower server or a rack server (including an independent server or a server cluster composed of a plurality of servers), and the like. As shown in fig. 7, the computer device 2 includes, but is not limited to, at least a memory 21, a processor 22, a network interface 23, and a priority-based mail sending apparatus 20, which are communicatively connected to each other through a system bus. Wherein:
in this embodiment, the memory 21 includes at least one type of computer-readable storage medium including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the storage 21 may be an internal storage unit of the computer device 2, such as a hard disk or a memory of the computer device 2. In other embodiments, the memory 21 may also be an external storage device of the computer device 2, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like provided on the computer device 2. Of course, the memory 21 may also comprise both internal and external memory units of the computer device 2. In this embodiment, the memory 21 is generally used for storing an operating system installed in the computer device 2 and various types of application software, such as the program codes of the priority-based mail sending apparatus 20 of the second embodiment. Further, the memory 21 may also be used to temporarily store various types of data that have been output or are to be output.
The network interface 23 may comprise a wireless network interface or a wired network interface, and the network interface 23 is generally used for establishing communication connection between the server 2 and other electronic systems. For example, the network interface 23 is used to connect the server 2 to an external terminal via a network, establish a data transmission channel and a communication connection between the server 2 and the external terminal, and the like. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth (Bluetooth), Wi-Fi, and the like. It is noted that fig. 7 only shows the computer device 2 with components 20-23, but it is to be understood that not all shown components are required to be implemented, and that more or less components may be implemented instead.
In this embodiment, the priority-based mail transmission apparatus 20 stored in the memory 21 may also be divided into one or more program modules, which are stored in the memory 21 and executed by one or more processors (in this embodiment, the processor 22) to complete the present invention.
For example, fig. 6 is a schematic diagram of program modules of the second embodiment of implementing the priority-based mail sending apparatus 20, in which the priority-based mail sending apparatus 20 may be divided into an obtaining module 200, a calculating module 202, a generating module 204, a sorting module 206, and a parsing and sending module 208. The program module referred to in the present invention refers to a series of computer program instruction segments capable of performing specific functions, and is more suitable than a program for describing the execution process of the priority-based mail sending apparatus 20 in the computer device 2. The specific functions of the program modules 200 and 208 have been described in detail in the second embodiment, and are not described herein again.
Example four
The present embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application mall, etc., on which a computer program is stored, which when executed by a processor implements corresponding functions. The computer-readable storage medium of this embodiment is used for storing a computer program, and when executed by a processor, implements the priority-based mail sending method of the first embodiment.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. A priority-based method for sending a mail, comprising:
acquiring the sending success time and the reading receipt time of various mails within a preset time period;
calculating the priority of each type of mail according to the sending success time, the reading receipt time and a preset priority algorithm;
acquiring mails to be sent in a current time period, and generating a mail sending request of each mail according to the mails to be sent, wherein the mails to be sent comprise at least one mail, and the mail sending request comprises a priority corresponding to the mail;
caching the mail sending requests in a request queue, and sequencing the mail sending requests in the request queue according to the priority of the mail sending requests;
and reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests, and sending mails according to the mail data obtained after analysis.
2. The priority-based mail sending method according to claim 1, wherein before the acquiring the sending success time and the reading receipt time of the plurality of types of mails within the preset time period, the method comprises:
monitoring the plurality of types of mails;
and establishing a timing task to record the sending success time and the reading receipt time of various types of mails.
3. The priority-based mail transmission method according to claim 1, wherein the buffering the mail transmission requests in a request queue, and the sorting the mail transmission requests in the request queue according to the priority of the mail transmission requests comprises:
sorting the mail sending requests in the request queue according to the priority and the cache time of the mail sending requests; wherein,
for the mail sending requests with different priorities, the mail sending request with low priority is ranked in front of the mail sending request with high priority;
for the mail sending requests with the same priority, the mail sending request with the early cache time is ranked before the mail sending request with the later cache time.
4. The priority-based mail transmission method according to claim 1, wherein the reading of the mail transmission requests from the request queue in order, the parsing of the mail transmission requests, and the sending of the mail according to the mail data obtained after the parsing includes:
creating a mail sending thread;
judging whether the position of the last read mail sending request is the last position of the request queue or not according to the mail sending thread, if so, returning to the first position of the request queue to read the mail sending request, and if not, starting to read the mail sending request from the next position of the last read position;
and analyzing the mail sending request based on the mail sending thread, and calling an application programming interface of a mail server to send the mail according to the mail data obtained after analysis.
5. The priority-based mail transmission method according to claim 4, wherein the steps of reading the mail transmission requests from the request queue in sequence, analyzing the mail transmission requests, and transmitting the mails according to the mail data obtained after the analysis comprise:
judging whether the mail is successfully sent or not through the mail sending thread;
if the transmission is successful, deleting the mail transmission request corresponding to the mail from the request queue;
if the transmission fails, deleting the mail transmission request corresponding to the mail from the request queue, and then re-caching the mail transmission request in the request queue and sequencing.
6. The priority-based mail transmission method according to claim 1, further comprising:
when sending the mails in the next time period, acquiring the unsent mails in the current time period and the newly added sent mails in the next time period;
and determining the priority of the newly added sent mails, and reordering the sending requests corresponding to the newly added mails and the unsent mails in the request queue according to the priority.
7. The priority-based mail transmission method according to claim 1, further comprising:
and caching the mail sending request and at least one mail in the mail sending request and the priority corresponding to the mail into a block chain.
8. A priority-based mail transmission apparatus, comprising:
the acquisition module is used for acquiring the sending success time and the reading receipt time of various mails within a preset time period;
the calculation module is used for calculating the priority of each type of mail according to the sending success time, the reading receipt time and a preset priority algorithm;
the generating module is used for acquiring mails to be sent in the current time period and generating a mail sending request of each mail according to the mails to be sent, wherein the mails to be sent comprise at least one mail, and the mail sending request comprises a priority corresponding to the mail;
the sorting module is used for caching the mail sending request in a request queue and sorting the mail sending requests in the request queue according to the priority of the mail sending request;
and the analysis sending module is used for reading the mail sending requests from the request queue in sequence, analyzing the mail sending requests and sending mails according to the mail data obtained after analysis.
9. A computer arrangement, characterized in that the computer arrangement comprises a memory, a processor, the memory having stored thereon a computer program being executable on the processor, the computer program, when being executed by the processor, realizing the steps of the priority-based mail transmission method according to any of the claims 1-7.
10. A computer-readable storage medium, having stored thereon, a computer program executable by at least one processor to cause the at least one processor to perform the steps of the priority-based mail transmission method according to any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011040403.0A CN112134790B (en) | 2020-09-28 | 2020-09-28 | Priority-based mail sending method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011040403.0A CN112134790B (en) | 2020-09-28 | 2020-09-28 | Priority-based mail sending method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112134790A true CN112134790A (en) | 2020-12-25 |
CN112134790B CN112134790B (en) | 2023-04-14 |
Family
ID=73843095
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011040403.0A Active CN112134790B (en) | 2020-09-28 | 2020-09-28 | Priority-based mail sending method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112134790B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050267941A1 (en) * | 2004-05-27 | 2005-12-01 | Frank Addante | Email delivery system using metadata on emails to manage virtual storage |
CN1783851A (en) * | 2004-12-03 | 2006-06-07 | 国际商业机器公司 | An email transaction system and method |
US20090113016A1 (en) * | 2007-10-24 | 2009-04-30 | Subhabrata Sen | Managing email servers by prioritizing emails |
CN103401764A (en) * | 2013-08-05 | 2013-11-20 | 浪潮(北京)电子信息产业有限公司 | Method and device for sending mails |
CN110380949A (en) * | 2019-05-24 | 2019-10-25 | 平安普惠企业管理有限公司 | Intranet e-mail sending method, device, computer equipment and storage medium |
CN111526081A (en) * | 2020-03-16 | 2020-08-11 | 中国平安人寿保险股份有限公司 | Mail forwarding method, device, equipment and storage medium |
-
2020
- 2020-09-28 CN CN202011040403.0A patent/CN112134790B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050267941A1 (en) * | 2004-05-27 | 2005-12-01 | Frank Addante | Email delivery system using metadata on emails to manage virtual storage |
CN1783851A (en) * | 2004-12-03 | 2006-06-07 | 国际商业机器公司 | An email transaction system and method |
US20090113016A1 (en) * | 2007-10-24 | 2009-04-30 | Subhabrata Sen | Managing email servers by prioritizing emails |
CN103401764A (en) * | 2013-08-05 | 2013-11-20 | 浪潮(北京)电子信息产业有限公司 | Method and device for sending mails |
CN110380949A (en) * | 2019-05-24 | 2019-10-25 | 平安普惠企业管理有限公司 | Intranet e-mail sending method, device, computer equipment and storage medium |
CN111526081A (en) * | 2020-03-16 | 2020-08-11 | 中国平安人寿保险股份有限公司 | Mail forwarding method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112134790B (en) | 2023-04-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111835467B (en) | Message sending method, device, computer equipment and storage medium | |
CN109657152B (en) | Push message sending method and device, electronic equipment and readable storage medium | |
CN111371892A (en) | High-concurrency distributed message pushing system and method | |
US20130318178A1 (en) | Systems and Methods for Processing Emails | |
CN110636130A (en) | Delayed message processing method and device, computer equipment and storage medium | |
CN108833443B (en) | Message transmission method and system and computer equipment | |
CN109714409B (en) | Message management method and system | |
CN112015815B (en) | Data synchronization method, device and computer readable storage medium | |
CN113672284B (en) | Instruction execution method, system, electronic equipment and storage medium | |
CN113038396B (en) | Scheduling method, device and equipment of short message channel and storage medium | |
CN114546681A (en) | Kafka-based message processing method, device, equipment and storage medium | |
CN112437001B (en) | Method and device for guaranteeing reliable delivery and consumption of messages | |
US10884827B2 (en) | Extensible alerts platform | |
CN108880994B (en) | Method and device for retransmitting mails | |
CN112134790B (en) | Priority-based mail sending method, device, equipment and storage medium | |
CN111884769B (en) | Message synchronization method and device | |
CN112969198A (en) | Data transmission method, terminal and storage medium | |
CN116151929A (en) | Order cooperative processing method, device, equipment and medium based on message queue | |
CN114827157B (en) | Cluster task processing method, device and system, electronic equipment and readable medium | |
CN113961334B (en) | Task processing method, device, equipment and storage medium | |
CN111488236B (en) | Order exception processing method, server, storage medium and processing device | |
CN110909086A (en) | Mail archiving method, system, computer device and computer readable storage medium | |
CN118316887B (en) | Flow surge elimination method and device for mass-sending information | |
CN115237625A (en) | Message aggregation method, system, computer equipment and storage medium | |
CN114978737B (en) | Comprehensive management system for Doppler weather radar data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |