Mail sending method, device, computer equipment and storage medium
The mail distribution server obtains the operator identification according to the mail type and uses multi-thread processing to solve the problem of low sending efficiency of the traditional mail system and improve the efficiency of mail sending.
Patent Information
- Application Number
- CN201811183668.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-11
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2038-10-11
AI Technical Summary
Traditional email systems are inefficient when sending emails, resulting in low efficiency.
The receiving mail distribution server obtains the operator identification according to the mail type, distributes the mail to the target mail collection, and performs asynchronous processing through threads in multiple sending units. Multi-threads are used to send mails concurrently, making full use of the memory resources of the gateway server.
It improves the efficiency of email sending and ensures that emails can be sent smoothly to various operator servers with the highest efficiency.
Smart Images

Figure CN109522103B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, apparatus, computer equipment, and storage medium for sending emails. Background Art
[0002] With the rapid development of Internet technology, e-mail has gradually replaced paper letters and become a common means of communication. In actual applications, mail system servers are often connected to business system servers. According to the different business needs of the business system, the mail system server needs to send mails to various operators. When sending mails, the mail system usually sends the mail to the mail gateway server, which then sends it to the corresponding operator server.
[0003] In traditional technology, when a gateway server sends emails, it usually directly sends the emails to be sent one by one in chronological order, resulting in low sending efficiency. Summary of the Invention
[0004] Based on this, it is necessary to provide an email sending method, device, computer equipment and storage medium that can improve the efficiency of email sending in order to address the above technical problems.
[0005] A method for sending an email, comprising:
[0006] Receive emails to be sent by the email distribution server according to the email type;
[0007] Obtaining an operator identifier corresponding to the to-be-sent email, assigning the to-be-sent email to a target email set corresponding to the operator identifier, and determining a target sending unit corresponding to the target email set from a plurality of sending units according to the operator identifier, wherein the target sending unit is configured to run a first thread and a second thread;
[0008] Selecting a preset number of to-be-sent emails from the target email collection through the first thread, and writing the obtained to-be-sent emails into a corresponding to-be-sent queue;
[0009] The second thread reads the mails to be sent from the queue to be sent, and sends the read mails to be sent.
[0010] In one embodiment, before selecting a preset number of emails to be sent from the target email set through the first thread, the method includes:
[0011] Get the number of historical emails to be sent corresponding to each operator ID;
[0012] Determining the queue capacity of the queue to be sent according to the number of historical emails to be sent corresponding to each operator identifier;
[0013] The number of emails to be sent selected by the first thread is determined according to the queue capacity of the queue to be sent.
[0014] In one embodiment, the target sending unit is configured to run a plurality of second threads, and the reading of the to-be-sent emails from the to-be-sent queue by the second threads includes:
[0015] Arranging the plurality of second threads in order of access time so that the plurality of second threads access the queue to be sent in sequence;
[0016] When any one of the second threads starts to read the mail to be sent, it acquires the queue lock and releases the queue lock after the reading is successful.
[0017] In one embodiment, the target sending unit is further configured to run a third thread. After sending the read email to be sent, the method further includes:
[0018] Writing the sent email into the sent queue through the second thread;
[0019] The sent emails are read from the sent queue by the third thread, and the current status of the obtained sent emails is stored in a database.
[0020] In one embodiment, the target sending unit is further configured to run a fourth thread, and the method further comprises: obtaining, through the fourth thread, the running status of the first thread, the second thread, and the third thread, and obtaining the sending results of each of the to-be-sent emails within a preset time period, and calculating the sending success rate according to the sending results;
[0021] When the running state and the sending success rate meet a preset adjustment condition, a preset adjustment step is executed through the fourth thread.
[0022] A mail sending device, comprising:
[0023] The mail receiving module is used to receive mails to be sent by the mail distribution server according to the mail type;
[0024] an operator identification acquisition module, configured to acquire the operator identification corresponding to the to-be-sent email, assign the to-be-sent email to a target email set corresponding to the operator identification, and determine a target sending unit corresponding to the target email set from a plurality of sending units according to the operator identification;
[0025] The sending module includes multiple sending units, each of which is used to run a first thread and a second thread. The first thread selects a preset number of emails to be sent from the target email collection and writes the obtained emails to be sent into a corresponding queue to be sent. The second thread reads the emails to be sent from the queue to be sent and sends the read emails to be sent.
[0026] In one embodiment, the apparatus further comprises:
[0027] The email quantity determination module is used to obtain the historical number of emails to be sent corresponding to each operator identifier; determine the queue capacity of the queue to be sent based on the historical number of emails to be sent corresponding to each operator identifier; and determine the number of emails to be sent selected by the first thread based on the queue capacity of the queue to be sent.
[0028] In one embodiment, the sending unit is used to run multiple second threads, arrange the multiple second threads in order of access time so that the multiple second threads access the queue to be sent in sequence; when any second thread starts to read the email to be sent, it obtains the queue lock, and releases the queue lock after the reading is successful.
[0029] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0030] Receive emails to be sent by the email distribution server according to the email type;
[0031] Obtaining an operator identifier corresponding to the to-be-sent email, assigning the to-be-sent email to a target email set corresponding to the operator identifier, and determining a target sending unit corresponding to the target email set from a plurality of sending units according to the operator identifier, wherein the target sending unit is configured to run a first thread and a second thread;
[0032] Selecting a preset number of to-be-sent emails from the target email collection through the first thread, and writing the obtained to-be-sent emails into a corresponding to-be-sent queue;
[0033] The second thread reads the mails to be sent from the queue to be sent, and sends the read mails to be sent.
[0034] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0035] Receive emails to be sent by the email distribution server according to the email type;
[0036] Obtaining an operator identifier corresponding to the to-be-sent email, assigning the to-be-sent email to a target email set corresponding to the operator identifier, and determining a target sending unit corresponding to the target email set from a plurality of sending units according to the operator identifier, wherein the target sending unit is configured to run a first thread and a second thread;
[0037] Selecting a preset number of to-be-sent emails from the target email collection through the first thread, and writing the obtained to-be-sent emails into a corresponding to-be-sent queue;
[0038] The second thread reads the mails to be sent from the queue to be sent, and sends the read mails to be sent.
[0039] The above-mentioned email sending method, device, computer equipment and storage medium receive the emails to be sent sent by the email distribution server according to the email type, obtain the operator identification corresponding to the email to be sent, allocate the email to be sent to the target email set corresponding to the operator identification, and determine the target sending unit corresponding to the target email set according to the operator identification. The target sending unit is used to run a first thread and a second thread, and a preset number of emails to be sent are selected from the target email set through the first thread, and the obtained emails to be sent are written into the corresponding queue to be sent. The emails to be sent are read from the queue to be sent through the second thread, and the read emails to be sent are sent. In this application, since the emails are sent independently according to the email type and operator identification when sending, and by running multiple second threads, the memory resources of the gateway server can be fully utilized to ensure that the emails can be sent to each operator server with the highest efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is an application scenario diagram of an email sending method in one embodiment;
[0041] Figure 2 Schematic diagram of a flow chart of a method for sending an email in one embodiment;
[0042] Figure 3 This is a structural block diagram of an email sending device in one embodiment;
[0043] Figure 4 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0045] The email sending method provided by this application can be applied to Figure 1 The illustrated application environment includes an email distribution server 102, at least two gateway servers 104, and an email operator server 106. The email distribution server 102 and the email operator server 106 each communicate with the gateway server 104 via a network. After receiving an email to be sent from the email distribution server 102 based on the email type, the gateway server 104 obtains the operator identifier corresponding to the email to be sent, assigns the email to be sent to a target email set corresponding to the operator identifier, and determines a target sending unit corresponding to the target email set based on the operator identifier. The target sending unit runs a first thread and a second thread. The first thread selects a preset number of emails to be sent from the target email set, writes the obtained emails to be sent to a corresponding queue to be sent, and reads the emails to be sent from the queue to be sent via a second thread, and sends the read emails to be sent to the corresponding email operator server 106. The email distribution server 102 and the email operator server 106 can be implemented as independent servers or as a server cluster consisting of multiple servers.
[0046] In one embodiment, Figure 2 As shown, a mail sending method is provided, which is applied to Figure 1 Taking the gateway server 104 in FIG. 1 as an example, the method includes the following steps:
[0047] Step S202: receiving the email to be sent sent by the email distribution server according to the email type.
[0048] Specifically, the email distribution server first determines the email type of the email to be sent based on the purpose of the email. In one embodiment, the email type may include marketing emails and service emails. Corresponding email templates can be set for marketing emails and service emails. When sending emails, the email category to which the email to be sent belongs is determined based on the type of the email template corresponding to the email to be sent. In other words, when the email template used by the email to be sent is the email template corresponding to the marketing email, the email type of the email to be sent is determined to be a marketing email. When the email template used by the email to be sent is the email template corresponding to the service email, the email type of the email to be sent is determined to be a server email. Emails to be sent that do not use email templates can also be determined to be service emails.
[0049] Furthermore, the mail distribution server sends the mail to be sent to the corresponding gateway server according to the mail type. In one embodiment, at least two gateway servers are deployed, one of which receives marketing mails sent by the mail distribution server, and the other receives service mails sent by the mail distribution server.
[0050] Step S204: obtain the operator identifier corresponding to the email to be sent, assign the email to be sent to the target email set corresponding to the operator identifier, and determine the target sending unit corresponding to the target email set from multiple sending units according to the operator identifier. The target sending unit is used to run the first thread and the second thread.
[0051] The carrier corresponding to the email to be sent refers to the mail carrier to which the recipient's address belongs. For example, if the recipient's address is 12XXX67@qq.com, the mail carrier corresponding to the email to be sent is Tencent. The carrier identifier corresponding to the email to be sent is used to uniquely identify the carrier to which the email is to be sent. It can be composed of numbers, letters, other special symbols, or simply the name of the carrier. The sending unit refers to an independent memory space pre-allocated on the gateway server for processing email sending tasks.
[0052] Specifically, after receiving the email to be sent, the gateway server needs to send the email to the corresponding operator server according to the operator identifier corresponding to the email to be sent. To ensure that the emails of each operator can be sent successfully, the emails can be classified according to different operators. For each classification, an independent sending unit is pre-assigned. In this way, each sending unit can send emails specifically for its corresponding operator, thereby avoiding the situation where the emails of other operators cannot be sent smoothly due to a sharp increase in the number of emails of a certain operator in a short period of time. Among them, each sending unit is bound to the operator identifier of its corresponding operator in advance.
[0053] In one embodiment, each operator may be sorted according to the number of historical emails corresponding to each operator, and then a predetermined number of operators ranked first are each allocated a sending unit, while other operators with smaller sending volumes are uniformly allocated a sending unit.
[0054] In this embodiment, after the gateway server receives the email to be sent, it can obtain the operator identifier corresponding to the email to be sent based on the recipient address of the email to be sent, and then add the email to be sent to the target email collection corresponding to the operator identifier. Due to the binding relationship established in advance between the sending unit and the operator identifier, after the email to be sent is added to the target email collection, the target sending unit corresponding to the target email collection can be determined from the multiple sending units based on the operator identifier.
[0055] Step S206: Select a preset number of to-be-sent emails from the target email collection through the first thread, and write the obtained to-be-sent emails into a corresponding to-be-sent queue.
[0056] Specifically, multiple sending units are pre-set on the gateway mail server, and each sending unit independently sends mails for its corresponding operator. For each sending unit, when sending mails, at least one first thread can be run, and then a preset number of mails to be sent are selected from the target mail collection corresponding to the sending unit through the first thread, and the obtained mails to be sent are written into the queue to be sent in the sending unit.
[0057] In one embodiment, the number of emails to be sent selected by the first thread corresponding to each sending unit can be determined based on the historical number of emails to be sent of the operator corresponding to the sending unit. Specifically, the historical number of emails to be sent corresponding to each operator identifier can be obtained first, and then the queue capacity of the queue to be sent can be determined based on the historical number of emails to be sent corresponding to each operator identifier. Finally, the number of emails to be sent selected by the first thread can be determined based on the queue capacity of the queue to be sent.
[0058] Step S208: Read the email to be sent from the queue to be sent through the second thread, and send the read email to be sent.
[0059] Specifically, each sending unit further runs a second thread, reads the emails to be sent from the to-be-sent queue through the second thread, and sends the read emails to be sent to the operator server corresponding to the sending unit.
[0060] In one embodiment, a sending unit can run multiple second threads, where the number of second threads corresponding to each sending unit can be determined by the historical number of pending emails for the operator corresponding to each sending unit. Specifically, the total number of pending emails for the operator corresponding to each sending unit within a preset time period (e.g., the previous day) is first obtained. Then, the total number of threads available for execution on the gateway server is obtained. The number of second threads corresponding to each sending unit is determined proportionally based on the total number of pending emails for the operator corresponding to each sending unit within the preset time period and the total number of threads available for execution on the gateway server. For example, if there are three sending units on the gateway server, namely A, B, and C, and the historical number of pending emails corresponding to A, B, and C is 10,000, 20,000, and 30,000, respectively, and the total number of second threads available for execution on the gateway server is 6, then the number of second threads corresponding to sending unit A is 6 x 1 / 6 = 1, the number of second threads corresponding to sending unit B is 6 x 2 / 6 = 2, and the number of second threads corresponding to sending unit C is 6 x 3 / 6 = 3.
[0061] In one embodiment, when sending emails to respective operator servers, the sending units may determine the time interval for sending emails according to the rate requirement agreed in advance with the operator, and then send the emails according to the time interval.
[0062] In the above-mentioned email sending method, the gateway server receives the emails to be sent sent by the email distribution server according to the email type, obtains the operator identifier corresponding to the email to be sent, and allocates the email to be sent to the target email set corresponding to the operator identifier, and determines the target sending unit corresponding to the target email set from multiple sending units according to the operator identifier. The target sending unit is used to run the first thread and the second thread, and selects a preset number of emails to be sent from the target email set through the first thread, and writes the obtained emails to be sent into the corresponding queue to be sent, and reads the emails to be sent from the queue to be sent through the second thread, and sends the read emails to be sent. In this application, since when sending emails, the emails are sent independently according to the email type and operator identifier, and by running multiple second threads, the memory resources of the gateway server can be fully utilized to ensure that the emails can be sent to each operator server with the highest efficiency.
[0063] In one embodiment, in step S206, before selecting a preset number of emails to be sent from the target email collection through the first thread, the above method also includes: obtaining the historical number of emails to be sent corresponding to each operator identifier; determining the queue capacity of the queue to be sent based on the historical number of emails to be sent corresponding to each operator identifier; and determining the number of emails to be sent selected by the first thread based on the queue capacity of the queue to be sent.
[0064] Among them, the historical number of emails to be sent refers to the number of emails that each operator needs to send within a preset time period before the current time. In one embodiment, to ensure that the selected emails can be sent efficiently, the historical email sending volume can be the number of emails to be sent by each operator on the previous day.
[0065] Specifically, after the gateway server obtains the historical number of emails to be sent for each operator, it determines the historical number of emails to be sent for each sending unit based on the historical number of emails to be sent for each operator. Specifically, the historical number of emails to be sent for all operators corresponding to the sending unit can be accumulated to obtain the historical number of emails to be sent for the sending unit. Of course, if there is only one operator corresponding to a sending unit, the historical number of emails to be sent corresponding to the operator is the historical number of emails to be sent for the sending unit.
[0066] Furthermore, the queue capacity of the queue to be sent corresponding to each sending unit is determined based on the historical number of pending emails of each sending unit and the total queue capacity that can be allocated by the gateway server. For example, there are three sending units on the gateway server, namely A, B, and C, where the historical number of pending emails corresponding to A, B, and C are 10,000, 20,000, and 30,000, respectively. The total queue capacity that can be allocated by the gateway server is 6,000 MB. Then, the queue capacity of the queue to be sent allocated to sending unit A is 6,000 x 1 / 6 = 1,000 MB, the queue capacity of the queue to be sent allocated to sending unit B is 6,000 x 2 / 6 = 2,000 MB, and the queue capacity of the queue to be sent allocated to sending unit C is 6,000 x 3 / 6 = 3,000 MB.
[0067] Furthermore, when the sending unit selects mails to be sent through the first thread, it ensures that the memory size of all selected mails to be sent does not exceed the queue capacity of the queue to be sent corresponding to the sending unit.
[0068] In the above embodiment, by ultimately determining the number of emails to be sent selected by the first thread based on the number of historical emails to be sent, it can be ensured that the operating resources of the gateway server are fully utilized, thereby improving the efficiency of email sending.
[0069] In one embodiment, in step S208, reading the to-be-sent email from the to-be-sent queue by the second thread includes: arranging multiple second threads in order of access time so that the multiple second threads access the to-be-sent queue in sequence; when any second thread starts to read the to-be-sent email, acquiring the queue lock, and releasing the queue lock after the reading is successful.
[0070] In this embodiment, each sending unit can run multiple second threads. For each sending unit, the multiple second threads accessing the queue to be sent can be arranged in order of access time. When any second thread starts to read the email to be sent from the queue to be sent, it obtains the queue lock and locks the queue to be sent through the queue lock, so that other threads cannot read data from the queue at the same time, thereby avoiding multiple threads reading the same email to be sent at the same time. When the second thread reading the email to be sent completes the reading, the queue lock is released. At this time, the second thread in the next position starts to read the email to be sent from the queue to be sent and locks the queue to be sent again.
[0071] In one embodiment, the target sending unit is also used to run a third thread. In step S208, after sending the read email to be sent, the method also includes: writing the sent email to the sent queue through the second thread; reading the sent email from the sent queue through the third thread, and storing the current status of the obtained sent email in the database.
[0072] Specifically, each target sending unit runs at least one third thread. After the second thread sends the email and writes the sent email into the sent queue, the third thread reads the sent email from the sent queue. At this time, the status of the read sent email is sent. Every time the third queue reads an email, the sent status of the email is written into the database.
[0073] In one embodiment, the target sending unit is also used to run a fourth thread, and the above method also includes: obtaining the running status of the first thread, the second thread and the third thread through the fourth thread, and obtaining the sending results of each email to be sent within a preset time period, and calculating the sending success rate based on the sending results; when the running status and the sending success rate meet the preset adjustment conditions, executing the preset adjustment steps through the fourth thread.
[0074] Specifically, each sending unit runs a fourth thread. Through the fourth thread, the running status of the first thread, the second thread and the third thread can be monitored to determine whether these threads are working normally. At the same time, the fourth thread can also obtain the sending results of each email sent by the sending unit. According to the sending results, the sending success rate of the sending unit within the preset time period can be calculated. The sending success rate can be obtained based on the ratio of the number of emails N successfully sent by the sending unit within the preset time period to the total number of emails sent by the sending unit within the preset time period, that is, the sending success rate = N / M.
[0075] In one embodiment, the preset adjustment step includes generating at least one of a warning message, adjusting the capacity of the queue to be sent, adjusting the number of threads, and adjusting the time interval for sending emails. Specifically, if the thread status is normal and the sending success rate is less than a preset threshold, the capacity of the queue to be sent, or the number of threads, or the time interval for sending emails can be adjusted; if the thread status is abnormal and the sending success rate is less than the preset threshold, a warning message is generated.
[0076] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0077] In one embodiment, Figure 3 As shown, an email sending device 300 is provided, comprising: an email receiving module 302, an operator identification obtaining module 304 and a sending module 306, wherein:
[0078] The mail receiving module 302 is used to receive mails to be sent by the mail distribution server according to the mail type;
[0079] The operator identification acquisition module 304 is used to obtain the operator identification corresponding to the email to be sent, assign the email to be sent to the target email set corresponding to the operator identification, and determine the target sending unit corresponding to the target email set from multiple sending units based on the operator identification;
[0080] The sending module 306 includes multiple sending units, each of which is used to run a first thread and a second thread. The first thread selects a preset number of emails to be sent from the target email collection and writes the obtained emails to be sent into a corresponding queue to be sent. The second thread reads the emails to be sent from the queue to be sent and sends the read emails to be sent.
[0081] In one embodiment, the above-mentioned device also includes: an email quantity determination module, which is used to obtain the historical number of emails to be sent corresponding to each operator identifier, determine the queue capacity of the queue to be sent according to the historical number of emails to be sent corresponding to each operator identifier, and determine the number of emails to be sent selected by the first thread according to the queue capacity of the queue to be sent.
[0082] In one embodiment, the sending unit is used to run multiple second threads, arrange the multiple second threads in order of access time so that the multiple second threads access the queue to be sent in sequence, and when any second thread starts to read the email to be sent, it obtains the queue lock and releases the queue lock after the reading is successful.
[0083] In one embodiment, the sending unit is further configured to run a third thread, write the sent emails into the sent queue via the second thread, read the sent emails from the sent queue via the third thread, and store the obtained current status of the sent emails into the database.
[0084] In one embodiment, the sending unit is also used to run a fourth thread, obtain the running status of the first thread, the second thread and the third thread through the fourth thread, and obtain the sending results of each email to be sent within a preset time period, calculate the sending success rate based on the sending results, and when the running status and the sending success rate meet the preset adjustment conditions, execute the preset adjustment steps through the fourth thread.
[0085] For the specific definition of the email sending device, please refer to the definition of the email sending method above and will not be repeated here. Each module in the above-mentioned email sending device can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor of the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each of the above modules.
[0086] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data related to emails. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements an email sending method.
[0087] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0088] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the following steps when executing the computer program: receiving an email to be sent sent by an email distribution server according to the email type; obtaining an operator identifier corresponding to the email to be sent, allocating the email to be sent to a target email set corresponding to the operator identifier, and determining a target sending unit corresponding to the target email set from multiple sending units according to the operator identifier, the target sending unit being used to run a first thread and a second thread; selecting a preset number of emails to be sent from the target email set through the first thread, and writing the obtained emails to be sent into a corresponding queue to be sent; reading the emails to be sent from the queue to be sent through the second thread, and sending the read emails to be sent.
[0089] In one embodiment, before selecting a preset number of emails to be sent from the target email collection through the first thread, the processor also implements the following steps when executing the computer program: obtaining the historical number of emails to be sent corresponding to each operator identifier; determining the queue capacity of the queue to be sent based on the historical number of emails to be sent corresponding to each operator identifier; and determining the number of emails to be sent selected by the first thread based on the queue capacity of the queue to be sent.
[0090] In one embodiment, the target sending unit is used to run multiple second threads, and read the to-be-sent emails from the to-be-sent queue through the second threads, including: arranging the multiple second threads in order of access time so that the multiple second threads access the to-be-sent queue in sequence; when any second thread starts to read the to-be-sent email, it obtains the queue lock, and releases the queue lock after the reading is successful.
[0091] In one embodiment, the target sending unit is also used to run a third thread. After sending the read email to be sent, the processor also implements the following steps when executing the computer program: writing the sent email to the sent queue through the second thread; reading the sent email from the sent queue through the third thread, and storing the current status of the obtained sent email in the database.
[0092] In one embodiment, the target sending unit is also used to run a fourth thread, and the processor also implements the following steps when executing the computer program: obtaining the running status of the first thread, the second thread and the third thread through the fourth thread, and obtaining the sending results of each email to be sent within a preset time period, and calculating the sending success rate based on the sending results; when the running status and the sending success rate meet the preset adjustment conditions, executing the preset adjustment steps through the fourth thread.
[0093] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: receiving an email to be sent sent by an email distribution server according to the email type; obtaining an operator identifier corresponding to the email to be sent, allocating the email to be sent to a target email set corresponding to the operator identifier, and determining a target sending unit corresponding to the target email set from multiple sending units according to the operator identifier, the target sending unit being used to run a first thread and a second thread; selecting a preset number of emails to be sent from the target email set through the first thread, and writing the obtained emails to be sent into a corresponding queue to be sent; reading the emails to be sent from the queue to be sent through the second thread, and sending the read emails to be sent.
[0094] In one embodiment, before selecting a preset number of emails to be sent from the target email collection through the first thread, the computer program also implements the following steps when executed by the processor: obtaining the historical number of emails to be sent corresponding to each operator identifier; determining the queue capacity of the queue to be sent based on the historical number of emails to be sent corresponding to each operator identifier; and determining the number of emails to be sent selected by the first thread based on the queue capacity of the queue to be sent.
[0095] In one embodiment, the target sending unit is used to run multiple second threads, and read the to-be-sent emails from the to-be-sent queue through the second threads, including: arranging the multiple second threads in order of access time so that the multiple second threads access the to-be-sent queue in sequence; when any second thread starts to read the to-be-sent email, it obtains the queue lock, and releases the queue lock after the reading is successful.
[0096] In one embodiment, the target sending unit is also used to run a third thread. After the read email to be sent is sent, the computer program also implements the following steps when executed by the processor: writing the sent email to the sent queue through the second thread; reading the sent email from the sent queue through the third thread, and storing the current status of the obtained sent email in the database.
[0097] In one embodiment, the target sending unit is also used to run a fourth thread, and when the computer program is executed by the processor, the following steps are also implemented: obtaining the running status of the first thread, the second thread and the third thread through the fourth thread, and obtaining the sending results of each email to be sent within a preset time period, and calculating the sending success rate based on the sending results; when the running status and the sending success rate meet the preset adjustment conditions, the preset adjustment steps are executed through the fourth thread.
[0098] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0099] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0100] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for sending an email, the method comprising: Receive the mails to be sent by the mail distribution server according to the mail type; Obtaining an operator identifier corresponding to the to-be-sent email, assigning the to-be-sent email to a target email set corresponding to the operator identifier, and determining a target sending unit corresponding to the target email set from a plurality of sending units according to the operator identifier, wherein the target sending unit is used to run a first thread and a second thread; Selecting a preset number of to-be-sent emails from the target email collection through the first thread, and writing the obtained to-be-sent emails into a corresponding to-be-sent queue; Reading the to-be-sent mail from the to-be-sent queue through the second thread, and sending the read to-be-sent mail; Before selecting a preset number of emails to be sent from the target email set through the first thread, the method includes: Get the number of historical emails to be sent corresponding to each operator ID; Determine the queue capacity of the queue to be sent according to the number of historical emails to be sent corresponding to each of the operator identifiers; Determining a preset number of emails to be sent selected by the first thread according to the queue capacity of the queue to be sent; The target sending unit is used to run a plurality of second threads, and the reading of the to-be-sent mails from the to-be-sent queue by the second threads includes: Arranging the plurality of second threads in order of access time so that the plurality of second threads access the queue to be sent in sequence; When any of the second threads starts to read the mail to be sent, it acquires the queue lock, and releases the queue lock after the reading is successful.
2. The method according to claim 1, characterized in that The target sending unit is further used to run a third thread. After sending the read email to be sent, the method further includes: Writing the sent mail into the sent queue through the second thread; The sent mails are read from the sent queue by the third thread, and the current status of the obtained sent mails is stored in the database.
3. The method according to claim 2, characterized in that The target sending unit is further used to run a fourth thread, and the method further includes: obtaining the running status of the first thread, the second thread and the third thread through the fourth thread, and obtaining the sending results of each of the to-be-sent emails within a preset time period, and calculating the sending success rate according to the sending results; When the running state and the sending success rate meet the preset adjustment conditions, the preset adjustment steps are executed through the fourth thread.
4. A mail sending device, characterized in that: The device comprises: The mail receiving module is used to receive mails to be sent by the mail distribution server according to the mail type; An operator identification acquisition module, used to acquire the operator identification corresponding to the to-be-sent email, assign the to-be-sent email to a target email set corresponding to the operator identification, and determine a target sending unit corresponding to the target email set from a plurality of sending units according to the operator identification; The sending module includes the target sending unit, the target sending unit is used to run a first thread and a second thread, select a preset number of to-be-sent emails from the target email set through the first thread, and write the obtained to-be-sent emails into a corresponding to-be-sent queue, read the to-be-sent emails from the to-be-sent queue through the second thread, and send the read to-be-sent emails; The device also includes: The mail quantity determination module is used to obtain the number of historical mails to be sent corresponding to each operator identifier; determine the queue capacity of the queue to be sent according to the number of historical mails to be sent corresponding to each operator identifier; and determine the preset number of mails to be sent selected by the first thread according to the queue capacity of the queue to be sent; The target sending unit is also used to run multiple second threads, arrange the multiple second threads in order of access time so that the multiple second threads access the queue to be sent in sequence, and when any second thread starts to read the email to be sent, it obtains the queue lock and releases the queue lock after the reading is successful.
5. The device according to claim 4, characterized in that The target sending unit is also used to run a third thread, write the sent email into the sent queue through the second thread, read the sent email from the sent queue through the third thread, and store the obtained current status of the sent email into the database.
6. The device according to claim 5, characterized in that The target sending unit is also used to run a fourth thread, obtain the running status of the first thread, the second thread and the third thread through the fourth thread, and obtain the sending results of each of the emails to be sent within a preset time period, calculate the sending success rate according to the sending results, and when the running status and the sending success rate meet the preset adjustment conditions, execute the preset adjustment steps through the fourth thread.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Scanning Email electronic mail group transmitting method
CN1532694A
