What I have done so far
I use POP3 package to read all my emails from my mailbox.
I received a raw email from the POP3
function which shown at the example below. (I omitted some information)
Issue
I'm facing the issue to extract the information from it.
I used the mail to extract the information, but unfortunately, this package cannot extract information from the raw email.
Seeking for help
Is there any method or package there which can help me to extract the information from the raw email?
Methods I had tried
// Retrieve all the email from your mailbox
msgs, _, error := connection.ListAll()
// Convert a chunk of integer to raw email
data, _ := connection.Retr(msgs[0])
// Extract Email Address
to, _ := mail.ParseAddress(data)
Error I am facing
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x5819ed]
Raw Email Example
From:
To:
Subject:
Thread-Topic:
Thread-Index: AdPgWzcFT3FjbSbUT1ycoU2ioB1bKAAAAHuA
X-MS-Exchange-MessageSentRepresentingType: 1
Date:
Message-ID:
Accept-Language: en-SG, en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 04
X-MS-Exchange-Organization-AuthSource:
X-MS-Has-Attach:
X-MS-Exchange-Organization-Network-Message-Id:
8c1e141b-c3ba-4471-0526-08d5b3b59967
X-MS-TNEF-Correlator:
Content-Type: multipart/alternative;
boundary="_002_b1a01aa36e1c4b3d9969a7bbb856bd3b"
MIME-Version: 1.0
--_002_b1a01aa36e1c4b3d9969a7bbb856bd3b
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
PGh0bWwgeG1sbnM6dj0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTp2bWwiIHhtbG5zOm89InVy
bjpzY2hlbWFzLW1pY3Jvc29mdC1jb206b2ZmaWNlOm9mZmljZSIgeG1sbnM6dz0idXJuOnNjaGVt
YXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6d29yZCIgeG1sbnM6bT0iaHR0cDovL3NjaGVtYXMubWlj
cm9zb2Z0LmNvbS9vZmZpY2UvMjAwNC8xMi9vbW1sIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv
VFIv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