EmailService provides an http interface, a mailing queue, a mailing result notification, and a notification failure retry queue.
git clone https://github.com/yue-best-practices/email-service.git temp_folder
make docker
This command will build the application and package it as a docker image file.The default image is email-service:0.0.1
.You can modify it in the docker-config/Dockerfile
file.
make clean
This command will clear the dependency files generated by building the docker image file.
You need to configure the docker-compose.xml file according to your own information. The following is the meaning of the specific environment variable configuration information.
ENV Variable | Comment | Default |
---|---|---|
PORT |
Http service port | 8001 |
MAX_QUEUE_LEN |
Mail queue channel buffer length. This number can increase the number of concurrent. | 5 |
RETRY_QUEUE_LEN |
Notification failure retry queue channel buffer length. | 5 |
RETRY_TIME_EXPRESS |
The notification fails the retry strategy. Multiple notifications are separated by the symbol | , and the system will send the notification again after the failure. (Unit: minute) |
5|15|30 |
USER |
Default mail sender account. If not set, set it when adding a send mail task. | |
PASSWORD |
Default password of the sender's account | |
SMTP_HOST |
Default mail sending account host | |
SMTP_PORT |
Default sending account host port | |
NICK_NAME |
Default sender's nickname |
Use the command make run
or use the docker-compose.xml
file.
Use the command make stop
or use the docker-compose.xml
file.
- Add an email task
URL:/putTask/:id
Method:PUT
Param:
{
"user":"[email protected]",
"password":"123456passwd",
"smtpHost":"smtp.mxhichina.com",
"smtpPort":"465",
"contentType":"Content-Type: text/html; charset=UTF-8",
"to":["[email protected]","[email protected]"],
"subject":"Test",
"body":"<h1>Test</h1>Hello,world!",
"notifyUrl":"http://127.0.0.1:8000/test",
"isSSL":true
}
If you need to send mail via SSL, set the
isSSL
parameter totrue
, otherwise you will not pass this parameter.
Response:
{
"code":200,
"message":"OK"
}
Url: The notifyUrl
that you set
Method:POST
Param:
Parameter | Data Type | Description |
---|---|---|
externalId | string |
The id when you requested to add a mailing task |
status | string |
Mail delivery result SUCCESS or FAILED |
message | string |
If the transmission is successful, it is OK , otherwise it is a failure message. |
Response:
statusCode
:200
body
:success
If the response to the notification interface is not the same, then the notification will be retried