As using golang imap to download the email and attachment?

Good day, maybe someone did tell me maybe there is Liba which does what you need.
You need to get the last n messages from your mailbox - from each letter to get the title, recipient, sender, time and date and any attachments(the attachments to save to the server).
Or who did the saving investment? By reading messages and data from them is not a problem but something still cannot save the attachment.
March 30th 20 at 00:09
1 answer
March 30th 20 at 00:11
switch h := p.Header.(type) {
//case mail.TextHeader:
//// This is the message''s text (can be plain-text or HTML)
//b, _ := ioutil.ReadAll(p.Body)
//log.Println("Got text: %v", string(b))
case mail.AttachmentHeader:
// This is an attachment
filename, _ := h.Filename()
//log.Println("Got attachment: %v", filename)

for _, checkFileName := range checkFileNames {
//if the name of the attachment to the letter coincides with the downloadable in the price
if strings.Contains(filename, checkFileName) == true {
log.Println("Downloading file: ", filename)

//create a file
output, err := os.Create(filename)
if err != nil {
fmt.Println("Error while creating", "-", err)
defer output.Close()

//write the bytes to a file
_, err = io.Copy(output, p.Body)
if err != nil {
fmt.Println("Error while downloading", "-", err)

Find more questions by tags Go