connection and login ok
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
|
||||
type MailBox struct {
|
||||
Server string
|
||||
User string
|
||||
Password string
|
||||
Client *imapclient.Client
|
||||
}
|
||||
|
||||
@@ -22,11 +24,21 @@ func (mb *MailBox) Connect() error {
|
||||
WordDecoder: &mime.WordDecoder{CharsetReader: charset.Reader},
|
||||
}
|
||||
var err error
|
||||
mb.Client, err = imapclient.DialStartTLS(mb.Server, options)
|
||||
mb.Client, err = imapclient.DialTLS(mb.Server, options)
|
||||
if err != nil {
|
||||
log.Println("Error connnecting to", mb.Server, ":", err)
|
||||
return err
|
||||
}
|
||||
log.Println("Connected")
|
||||
err = mb.Client.Login(mb.User, mb.Password).Wait()
|
||||
if err != nil {
|
||||
log.Fatal("failed to login:", err)
|
||||
}
|
||||
log.Println("Logged in")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mb *MailBox) Close() {
|
||||
mb.Client.Close()
|
||||
}
|
||||
|
Reference in New Issue
Block a user