parent
096424ff3b
commit
d4768ad367
|
|
@ -56,7 +56,7 @@ func (e *Emailer) ReadIMAP() (chan *mail.Message, error) {
|
|||
from := uint32(1)
|
||||
to := mbox.Messages
|
||||
if e.Limit > 0 && to > uint32(e.Limit) {
|
||||
to = uint32(e.Limit)
|
||||
from = to - uint32(e.Limit-1)
|
||||
}
|
||||
seqset := new(imap.SeqSet)
|
||||
seqset.AddRange(from, to)
|
||||
|
|
@ -100,7 +100,7 @@ func (e *Emailer) ReadPOP3() (chan *mail.Message, error) {
|
|||
return nil, err
|
||||
}
|
||||
for j, id := range ids {
|
||||
if e.Limit > 0 && j >= e.Limit {
|
||||
if e.Limit > 0 && len(ids)-1-j >= e.Limit {
|
||||
break
|
||||
}
|
||||
raw, err := c.Retr(id)
|
||||
|
|
|
|||
23
recv.go
23
recv.go
|
|
@ -1,9 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"local/args"
|
||||
"local/sandbox/contact/contact"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -23,6 +27,21 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
for msg := range msgs {
|
||||
log.Println(msg)
|
||||
b, _ := ioutil.ReadAll(io.LimitReader(msg.Body, 1024))
|
||||
s := strings.ReplaceAll(string(b), "\r\n", " ")
|
||||
s = strings.ReplaceAll(string(s), "\n", " ")
|
||||
s = strings.ReplaceAll(string(s), "\r", " ")
|
||||
if !strings.Contains(s, " ") {
|
||||
s = "..."
|
||||
}
|
||||
d, _ := msg.Header.Date()
|
||||
d = d.In(time.Local)
|
||||
fmt.Printf(
|
||||
"@%+v @%+v: %+v: %s\n",
|
||||
d.Format("06-01-02T15:04Z07"),
|
||||
msg.Header.Get("From"),
|
||||
msg.Header.Get("Subject"),
|
||||
s,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue