获取邮件内容

pull/30/head
taoshihan1991 4 years ago
parent 413cbc07ce
commit 77c4afc8e5

@ -153,6 +153,7 @@ func view(w http.ResponseWriter, r *http.Request) {
render.To=mail.To render.To=mail.To
render.Subject=mail.Subject render.Subject=mail.Subject
render.Date=mail.Date render.Date=mail.Date
render.HtmlBody=template.HTML(mail.Body)
}() }()
wg.Wait() wg.Wait()
tmpl.RenderView(w,render) tmpl.RenderView(w,render)

@ -60,7 +60,7 @@ func RenderView(w http.ResponseWriter,render interface{}){
</tr> </tr>
<tr> <tr>
<th scope="row">:</th> <th scope="row">:</th>
<td>Jacob</td> <td>{{.HtmlBody}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

@ -217,25 +217,26 @@ func GetMessage(server string, email string, password string,folder string,id ui
mailitem.Subject=s mailitem.Subject=s
} }
// Process each message's part // Process each message's part
//for { for {
// p, err := mr.NextPart() p, err := mr.NextPart()
// if err == io.EOF { if err == io.EOF {
// break break
// } else if err != nil { } else if err != nil {
// log.Fatal(err) //log.Fatal(err)
// } }
// switch h := p.Header.(type) {
// switch h := p.Header.(type) { case *mail.InlineHeader:
// case *mail.InlineHeader: // This is the message's text (can be plain-text or HTML)
// // This is the message's text (can be plain-text or HTML) b, _ := ioutil.ReadAll(p.Body)
// b, _ := ioutil.ReadAll(p.Body) mailitem.Body+=string(b)
// log.Println("Got text: ", string(b)) //body,_:=dec.Decode(string(b))
// case *mail.AttachmentHeader: log.Println("Got text: ", string(b))
// // This is an attachment case *mail.AttachmentHeader:
// filename, _ := h.Filename() // This is an attachment
// log.Println("Got attachment: ", filename) filename, _ := h.Filename()
// } log.Println("Got attachment: ", filename)
//} }
}
return mailitem return mailitem
} }
func GetDecoder()*mime.WordDecoder{ func GetDecoder()*mime.WordDecoder{

@ -14,6 +14,7 @@ type IndexData struct {
} }
type ViewData struct { type ViewData struct {
Folders map[string]int Folders map[string]int
HtmlBody template.HTML
MailItem MailItem
} }
type MailItem struct{ type MailItem struct{

Loading…
Cancel
Save