go-gomail / gomail

The best way to send emails in Go.
MIT License
4.33k stars 573 forks source link

Erro TLS #39

Closed jniltinho closed 8 years ago

jniltinho commented 8 years ago

undefined: tls in tls.Config

go build teste_email.go

command-line-arguments

./teste_email.go:16: undefined: tls in tls.Config

alexcesaro commented 8 years ago

Please explain what your problem is.

I guess you need to import crypto/tls in your tests. You should use goimports to automatically manage your imports.

jniltinho commented 8 years ago

No build :-(

Code

package main

import (
    "gopkg.in/gomail.v2"
)

func main() {
    m := gomail.NewMessage()
    m.SetHeader("From", "nilton@domain.com")
    m.SetHeader("To", "nilton@domain2.com")
    m.SetHeader("Subject", "Hello!")
    m.SetBody("text/html", "Hello <b>Nilton OS</b>!")

    // Send the email to Bob
    d := gomail.NewPlainDialer("mail.domain.com", 587, "nilton@domain.com", "1234567")
    d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
    if err := d.DialAndSend(m); err != nil {
        panic(err)
    }
}
jniltinho commented 8 years ago

:+1:

Add lib "crypto/tls"

OK,

Thank's

:-) Add plugin on SublimeText3 :-)

alexcesaro commented 8 years ago

You're welcome.

Which editor do you use? I greatly recommend using goimports.

pedromorgan commented 8 years ago

Maybe add this to FAQ,, for new-go-users = muppets like me.. trying to swim

import "crypto/tls"