func ResetConnection(conn *imap.Client, readOnly bool) error { // dont check for error because its possible it's already closed. conn.Close(!readOnly) _, err := imap.Wait(conn.Select("INBOX", readOnly)) if err != nil { return err } return nil }