go - smtp won't work in production, Unauthenticated even with credentials -


i having hell of time here. code works on local instance (osx) config:

mail.host = smtp.gmail.com mail.port = 25 mail.from = mysite.com mail.username = email@gmail.com 

but says unauthenticated in production (ubuntu 12.0.1):

here code (and can find of @ github.com/tanema/revel_mailer). authentication error thrown @ c.mail(username) line.

func (m *mailer) send(mail_args map[string]interface{}) error {   m.renderargs = mail_args   pc, _, _, _ := runtime.caller(1)   names := strings.split(runtime.funcforpc(pc).name(), ".")   m.template =  names[len(names)-2] + "/" + names[len(names)-1]    host, host_ok := revel.config.string("mail.host")   if !host_ok {     revel.error.println("mail host not set")   }   port, port_ok := revel.config.int("mail.port")   if !port_ok {     revel.error.println("mail port not set")   }    c, err := smtp.dial(fmt.sprintf("%s:%d", host, port))   if err != nil {     return err   }    if ok, _ := c.extension("starttls"); ok {     if err = c.starttls(nil); err != nil {       return err     }   }    from, from_ok := revel.config.string("mail.from")    if !from_ok {     revel.error.println("mail.from not set")   }     username, username_ok := revel.config.string("mail.username")    if !username_ok {     revel.error.println("mail.username not set")   }    if err = c.auth(smtp.plainauth(from, username, getpassword(), host)); err != nil {        return err   }    if err = c.mail(username); err != nil {     return err   }    if mail_args["to"] != nil {     m.to = makesafi(mail_args["to"]) //makesafi == make string array interface   }   if mail_args["cc"] != nil {     m.cc = makesafi(mail_args["cc"])   }   if mail_args["bcc"] != nil {     m.bcc = makesafi(mail_args["bcc"])   }    if len(m.to) + len(m.cc) + len(m.bcc) == 0 {     return fmt.errorf("cannot send email without recipients")   }    recipients := append(m.to, append(m.cc, m.bcc...)...)   _, addr := range recipients {     if err = c.rcpt(addr); err != nil {       return err     }   }   w, err := c.data()   if err != nil {     return err   }    mail, err := m.rendermail(w)   if err != nil {     return err   }    if revel.runmode == "dev" {     fmt.println(string(mail))   }    _, err = w.write(mail)   if err != nil {     return err   }   err = w.close()   if err != nil {     return err   }   return c.quit() } 

i cannot figure out problem is; please help.

edit:

so bit bullet , signed google apps , set domain , email. lead me believe mx records didnt change. tested out sending personal email again mx records set. no luck. idea if can setup mx records personal gmail email dont have pay google apps?

i developed gmail front-end , encountered similar problem. try following:

  1. try using ssl://smtp.gmail.com , port 465.

  2. log gmail account see if says 'an unauthorised third-party tried accesss account'. if do, grant app permission log in.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -