Hey Alex, tried sending mail with gomail v2 having some ish.
here is my code:
func contact(w http.ResponseWriter, req *http.Request) {
var s string
var e string
var m string
pd := pageData{
Title: "contact || CACCYE",
}
if req.Method == http.MethodPost {
s = req.FormValue("subject")
e = req.FormValue("mail")
m = req.FormValue("message")
pd.subject = s
pd.email = e
pd.msg = m
cb := gomail.NewMessage()
cb.SetHeader("From", e)
cb.SetHeader("To", "[email protected]", "[email protected]")
cb.SetHeader("Subject", s)
cb.SetBody("text/plain", m)
d := gomail.NewDialer("smtp.gmail.com", 587, "[email protected]",
"my_password")
// Send the email to Bob, Cora and Dan.
if err := d.DialAndSend(cb); err != nil {
panic(err)
}
}
err := tpl.ExecuteTemplate(w, "contact.gohtml", pd)
if err != nil {
log.Println(err)
}
}
when i submit it outputs:
2017/06/01 19:28:48 http: panic serving [::1]:50340: dial tcp: i/o timeout
goroutine 6 [running]:
net/http.(*conn).serve.func1(0xc42008c6e0)
/usr/local/go/src/net/http/server.go:1721 +0xd0
panic(0x709800, 0xc4200165a0)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
main.contact(0x8b6740, 0xc42013e2a0, 0xc42000ae00)
/home/connelblaze/go/src/github.com/connelevalsam/GoWebDev/001/src/sendmail/src/main/main.go:86
+0x5d3
net/http.HandlerFunc.ServeHTTP(0x769658, 0x8b6740, 0xc42013e2a0,
0xc42000ae00)
/usr/local/go/src/net/http/server.go:1942 +0x44
net/http.(*ServeMux).ServeHTTP(0x8e38e0, 0x8b6740, 0xc42013e2a0,
0xc42000ae00)
/usr/local/go/src/net/http/server.go:2238 +0x130
net/http.serverHandler.ServeHTTP(0xc42011e0b0, 0x8b6740, 0xc42013e2a0,
0xc42000ae00)
/usr/local/go/src/net/http/server.go:2568 +0x92
net/http.(*conn).serve(0xc42008c6e0, 0x8b6d40, 0xc420018680)
/usr/local/go/src/net/http/server.go:1825 +0x612
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2668 +0x2ce
2017/06/01 19:28:54 http: panic serving [::1]:50370: 534 5.7.14
<https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbv-
5.7.14
DmuGszjeM-IZqxmuGU8tCESBHyOZpR73mPqkWEM8N_WNfGXS69r7GhgMhUleDP6K90OYsN
5.7.14
tlAP9aQdv9X7UaZk_Y4Yv0z-ZaJ6fYCNbsPQg-9MFT1hZw5UkZ9G-Cih5BTZ9XZzPNjbtM
5.7.14
a7KwOetlkIzo_gD2u-h-pTluI6tfdHfQ70ROvEPzD4VPPjbfIyC1_lOF3YLTCWUVrLYauZ
5.7.14 hC7MYnXwQJhuRf2wLOK6VAvtetjvk> Please log in via your web browser and
5.7.14 then try again.
5.7.14 Learn more at
5.7.14 https://support.google.com/mail/answer/78754 w11sm13739759eda.63 -
gsmtp
goroutine 33 [running]:
net/http.(*conn).serve.func1(0xc4201361e0)
/usr/local/go/src/net/http/server.go:1721 +0xd0
panic(0x6fb7a0, 0xc42043f8e0)
/usr/local/go/src/runtime/panic.go:489 +0x2cf
main.contact(0x8b6740, 0xc4201442a0, 0xc420100b00)
/home/connelblaze/go/src/github.com/connelevalsam/GoWebDev/001/src/sendmail/src/main/main.go:86
+0x5d3
net/http.HandlerFunc.ServeHTTP(0x769658, 0x8b6740, 0xc4201442a0,
0xc420100b00)
/usr/local/go/src/net/http/server.go:1942 +0x44
net/http.(*ServeMux).ServeHTTP(0x8e38e0, 0x8b6740, 0xc4201442a0,
0xc420100b00)
/usr/local/go/src/net/http/server.go:2238 +0x130
net/http.serverHandler.ServeHTTP(0xc42011e0b0, 0x8b6740, 0xc4201442a0,
0xc420100b00)
/usr/local/go/src/net/http/server.go:2568 +0x92
net/http.(*conn).serve(0xc4201361e0, 0x8b6d40, 0xc4200f2d40)
/usr/local/go/src/net/http/server.go:1825 +0x612
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2668 +0x2ce
hope to hear from you
On Wednesday, September 2, 2015 at 12:55:26 PM UTC+1, Alexandre Cesaro
wrote:
>
> Hi,
>
> I just released the second version of Gomail
> <https://github.com/go-gomail/gomail>.
>
> There are quite a few backward-incompatible changes
> <https://github.com/go-gomail/gomail/blob/master/CHANGELOG.md> since
> Gomail v1 but it brings lots of good stuff:
>
> - A great focus was placed on performances. Gomail v2 is way more
> efficient than Gomail v1 to send a large number of emails (see the
> Daemon <https://godoc.org/gopkg.in/gomail.v2#example-package--Daemon>
> or Newsletter
> <https://godoc.org/gopkg.in/gomail.v2#example-package--Newsletter>
> examples).
> - The API is now clearer and way more flexible.
> - The documentation <https://godoc.org/gopkg.in/gomail.v2> improved
> and many examples were added.
> - All existing issues have been closed.
> - The minimum Go version is now 1.2 instead of 1.3. No external
> dependencies are used with Go 1.5.
>
> More info on Github: https://github.com/go-gomail/gomail
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.