smtp.SendMail fails after 10 minutes with EOF

Viewed 8127

I'm trying to send mail via the standard library SMTP package and it does nothing for exactly 10 minutes and then fails with an unhelpful End of File error I can't make sense of.

// excerpt from the calling function
// --- snip ---
if e := mailNotify(board, validPosts, ipMinusPort, delTime); e != nil {
    errorPage(w, tmpl, "Contact Administrator",
        "Email notification failed, please contact archive admin.")
    log.Println("ERROR: Failed to send notification email: " + e.Error())
}
// --- snip ---

func mailNotify(board *config.Board, validPosts []int64, 
                        ip string, delTime time.Time) error {

    addresses := strings.Split(board.NotifyAddr, ",")
    if len(addresses) < 1 {
        return nil
    }

    msg := new(bytes.Buffer)
    type values struct {
        IP      string
        Posts   []int64
        DelTime time.Time
    }
    t.ExecuteTemplate(msg, "post_reported", &values{ip, validPosts, delTime})
    auth:= smtp.PlainAuth("", board.NotifyAddr, board.NotifyPass,
        strings.Split(board.SMTPServer, ":")[0])
    return smtp.SendMail(board.SMTPServer, auth,
        board.FromEmail, addresses, msg.Bytes())
}

The exact message that gets logged is:

2012/07/25 22:57:58 ERROR: Failed to send notification email: EOF

I've log.Printf debugged this function and verified the values being sent at this point are valid. The email address is a real address on gmail.com and the password is correct, and board.SMTPServer is smtp.googlemail.com:465. I've tried storing the result of msg.Bytes() in a separate variable and taking the length to be sure that it was producing an byte array to send, and the length is indeed non-zero. I'm guessing the EOF is bubbling up from somwhere deeper in the standard library than the SendMail function itself, but I have no idea where it's choking and I don't know what I did to upset it.

1 Answers
Related