Answer the question
In order to leave comments, you need to log in
How to get From from Email Header (imap) in golang?
I can not find a solution, maybe someone worked with this. I can get the header:
2020/12/14 16:19:37 entity = {{[0xc00005a680 0xc00005a640 0xc00005a600 0xc00005a5c0 0xc00005a580 0xc00005a540 0xc00005a500 0xc00005a4c0 0xc00005a480 0xc00005a440 0xc00005a400 0xc00005a3c0 0xc00005a380 0xc00005a340 0xc00005a300 0xc00005a2c0 0xc00005a280 0xc00005a240 0xc00005a200 0xc00005a1c0] map [Authentication-Results: [0xc00005a340] Content-Type: [ 0xc00005a640] Date: [0xc00005a5c0] Dkim-Signature: [0xc00005a300] From: [0xc00005a480] Message-Id: [0xc00005a600] Mime-Version: [0xc00005a540] Received: [0xc00005a440 0xc00005a280 0xc00005a200 0xc00005a1c0] Return-Path: [0xc00005a680] Subject: [0xc00005a500] To:[0xc00005a4c0] X-Mailer:[0xc00005a580] X-Yandex-Internal:[0xc00005a240] X-Yandex-Sender-Uid:[0xc00005a400] X-Yandex-Spam:[0xc00005a3-c0] X-Yandex Status:[0xc00005a380] X-Yandex-Timemark:[0xc00005a2c0]]}}
for _, r := range msg.Body {
entity, err := message.Read(r)
if err != nil {
log.Fatal(err)
}
log.Println("entity = ",entity.Header)
Answer the question
In order to leave comments, you need to log in
The header type, if I'm not mistaken, should be MIMEHeader , i.e. this is a regular map[string][], where the key is the header + methods Get, Values
This is how you will see what is there at all (all the keys and values of the map)
And this is how you can get the first value of the header
log.Printf("entity: %+v\n", entity.Header)
log.Printf("entity: %+v\n", entity.Header.Get("From"))
log.Printf("entity: %+v\n", entity.Header.Values("To"))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question