Comments (5)
https://github.com/mxk/go-imap/tree/master/imap-demo
https://godoc.org/github.com/mxk/go-imap/imap#example-Client
from go-imap.
Thanks for the reply. I got the code run and fetched the subject from the code from your second link. However, the example in the second link does not answer the question how to get the body of the mail.
from go-imap.
You should have some understanding of the underlying protocol (RFC 3501) to use this package. The basic idea is that you would fetch "BODY[]" and then parse the response.
from go-imap.
Thanks. I finally figured out how to get it by reading RFC 3501. Here is some sample code:
cmd, _ = c.UIDFetch(set, "RFC822.HEADER", "RFC822.TEXT")
// Process responses while the command is running
fmt.Println("\nMost recent messages:")
for cmd.InProgress() {
// Wait for the next response (no timeout)
c.Recv(-1)
// Process command data
for _, rsp = range cmd.Data {
header := imap.AsBytes(rsp.MessageInfo().Attrs["RFC822.HEADER"])
uid := imap.AsNumber((rsp.MessageInfo().Attrs["UID"]))
body := imap.AsBytes(rsp.MessageInfo().Attrs["RFC822.TEXT"])
if msg, _ := mail.ReadMessage(bytes.NewReader(header)); msg != nil {
fmt.Println("|--", msg.Header.Get("Subject"))
fmt.Println("UID: ", uid)
fmt.Println(string(body))
}
}
cmd.Data = nil
c.Data = nil
}
from go-imap.
Hi?
When I print the body as shown above it comes in parts that consist of headers and a base64 encoded string...how do I separate the two (headers and base64 encoded string) so that I can decode the contents?
from go-imap.
Related Issues (20)
- demo of setting /Deleted flag would be helpful HOT 2
- STORE command returning unexpected status using Exchange HOT 3
- Login: panic: unhandled untagged response BYE HOT 2
- Support thirdparty logger through interface
- IDLE can't be interrupted using idleTerm() HOT 19
- BODYSTRUCTURE HOT 1
- Can't delete Message via UID HOT 2
- Exclusive client access violation when Idling imap client
- Debugging idea: log progress of a data transfer
- How to authenticate with this capabilities?
- How do you set mailbox flags HOT 2
- Allow for custom handlers in client HOT 1
- read: connection reset by peer
- where are the mails stored? eg with the APPEND command
- How to fetch only Unreaded email ?
- doesn't properly parse from address on *nix machines where email is from user (ie: (root))
- Repo renaming HOT 2
- Enable Sourcegraph HOT 1
- Should support SEARCH response with trailing whitespace? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-imap.