title: gomail noauth example crashes
body: <p>I am trying to follow <a href="https://godoc.org/gopkg.in/gomail.v2#example-package--NoAuth" rel="nofollow">this example</a>:</p>
  
  <pre><code>package main
  
  import (
      "gopkg.in/gomail.v2"
  )
  
  
  
  
  func main() {
      m := gomail.NewMessage()
      m.SetHeader("From", "from@example.com")
      m.SetHeader("To", "to@example.com")
      m.SetHeader("Subject", "Hello!")
      m.SetBody("text/plain", "Hello!")
  
      d := gomail.Dialer{Host: "localhost", Port: 587}
      if err := d.DialAndSend(m); err != nil {
          panic(err)
      }
  } //main
  </code></pre>
  
  <p>And I got this error:</p>
  
  <pre><code>panic: 454 4.7.0 TLS not available due to local problem
  
  goroutine 1 [running]:
  panic(0x244ca0, 0xc820010b20)
      /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
  main.main()
      /Users/kaiyin/IdeaProjects/gomail/main.go:19 +0x342
  exit status 2
  </code></pre>
  
  <p>I also tried disabling TLS and SSL:</p>
  
  <pre><code>    d := gomail.Dialer{Host: "localhost", Port: 587, SSL: false, TLSConfig: nil}
  </code></pre>
  
  <p>But the error still persists.</p>
  
  <hr>
  
  <p>I had a look into the mail.log (from postfix on osx 10.10):</p>
  
  <pre><code>Apr  7 14:28:05 kaiyins-mbp postfix/smtpd[64525]: warning: No server certs available. TLS won't be enabled
  Apr  7 14:28:05 kaiyins-mbp postfix/smtpd[64525]: connect from localhost[::1]
  Apr  7 14:28:05 kaiyins-mbp postfix/smtpd[64525]: lost connection after STARTTLS from localhost[::1]
  </code></pre>
  
  <p>So I generated certs like this:</p>
  
  <pre><code>cd /etc/postfix
  sudo openssl req -new -outform PEM -out smtpd.cert    -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM    -days 365 -x509
  </code></pre>
  
  <p>And changed postfix settings:</p>
  
  <pre><code>smtpd_enforce_tls                = no
  smtpd_tls_loglevel               = 1
  smtpd_use_tls                    = yes
  smtpd_tls_key_file               = /etc/postfix/smtpd.key
  smtpd_tls_cert_file              = /etc/postfix/smtpd.cert
  </code></pre>
  
  <p>Now I get a different error: </p>
  
  <pre><code>panic: x509: certificate signed by unknown authority
  
  goroutine 1 [running]:
  panic(0x26e3c0, 0xc8203e4b80)
      /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
  main.main()
      /Users/kaiyin/IdeaProjects/gomail/main.go:19 +0x32f
  exit status 2
  </code></pre>
  
  <hr>
  
  <p>I tried to generate a cert as instructed here: <a href="http://www.akadia.com/services/ssh_test_certificate.html" rel="nofollow">http://www.akadia.com/services/ssh_test_certificate.html</a></p>
  
  <p>And I got yet another error:</p>
  
  <pre><code>panic: x509: certificate is valid for Kaiyin Zhong, not localhost
  
  goroutine 1 [running]:
  panic(0x26a7e0, 0xc8203e6800)
      /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
  main.main()
      /Users/kaiyin/IdeaProjects/gomail/main.go:19 +0x32f
  exit status 2
  </code></pre>
  
  <p>I assumed that I got the server name wrong, so I did it all over again, with the server FQDN set to localhost:</p>
  
  <pre><code>Common Name (e.g. server FQDN or YOUR name) []:localhost
  </code></pre>
  
  <p>Then I got back to the previous error:</p>
  
  <pre><code>panic: x509: certificate signed by unknown authority
  
  goroutine 1 [running]:
  panic(0x26e3c0, 0xc8203e6800)
      /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
  main.main()
      /Users/kaiyin/IdeaProjects/gomail/main.go:19 +0x32f
  exit status 2
  </code></pre>