This is a REST API microservice of the mail client. To automate the receipt of data through mail attachments. For example: you are sent price lists by email with attached file and you need to parse the attachments data.
This microservice based on high performance, extensible, minimalist Go web framework Echo, IMAP client go-imap. For logging i`m use Logrus
The entire configuration is in a file config.toml
imap
- IMAP host addressimap_port
- IMAP portimap_user
- usernameimap_password
- passwordhttp_addr
- server bind address and portlog_level
- Level of logs: debug | warn | error
Before, you need a build programm or use a docker (be release later).
make build
The programm has been build app
application.
Note
The following logic should be implemented in your application:
- Read the messages in order and check for the from field, subject and attachment name
- If the message suits us, then we get an attachment (blob)
- Transfer the letter to one of the folders (LOADED|ERRORS). Well done!
- Repeat
The following REST API is used:
GET host/mails/list
- response list of mailboxes (folders).PUT host/mails/folder
with JSON data:{"folder":"FOLDER_NAME"}
- set current folder of mailbox.
GET host/messages/list?page=1
- list messages with response header info of total pagesX-Pagination-Page-Count
GET host/messages/last?count=100
- list of last messages. Use query parametercount
- что бы указать кол-во элементов
GET host/messages/:uid
- where uid
- id message from list.
Response data of message with array attachments
.
GET messages/download/:uid?index=0
:uid
- id message from listindex
- index attachments from view attachment
Response: - blob data
- Use secure TLS connection IMAP
- Migrate go-imap to v2
- Cover tests with Postman collections
Give a ⭐️ if this project helped you!
Made with ❤️ :) Thank you!