parent
096424ff3b
commit
d4768ad367
|
|
@ -56,7 +56,7 @@ func (e *Emailer) ReadIMAP() (chan *mail.Message, error) {
|
||||||
from := uint32(1)
|
from := uint32(1)
|
||||||
to := mbox.Messages
|
to := mbox.Messages
|
||||||
if e.Limit > 0 && to > uint32(e.Limit) {
|
if e.Limit > 0 && to > uint32(e.Limit) {
|
||||||
to = uint32(e.Limit)
|
from = to - uint32(e.Limit-1)
|
||||||
}
|
}
|
||||||
seqset := new(imap.SeqSet)
|
seqset := new(imap.SeqSet)
|
||||||
seqset.AddRange(from, to)
|
seqset.AddRange(from, to)
|
||||||
|
|
@ -100,7 +100,7 @@ func (e *Emailer) ReadPOP3() (chan *mail.Message, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for j, id := range ids {
|
for j, id := range ids {
|
||||||
if e.Limit > 0 && j >= e.Limit {
|
if e.Limit > 0 && len(ids)-1-j >= e.Limit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
raw, err := c.Retr(id)
|
raw, err := c.Retr(id)
|
||||||
|
|
|
||||||
23
recv.go
23
recv.go
|
|
@ -1,9 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"local/args"
|
"local/args"
|
||||||
"local/sandbox/contact/contact"
|
"local/sandbox/contact/contact"
|
||||||
"log"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -23,6 +27,21 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
for msg := range msgs {
|
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