Created
September 11, 2014 03:09
-
-
Save ceb10n/f27e5bf166a090662783 to your computer and use it in GitHub Desktop.
exemplo de go routine e enviar email para o blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/smtp" | |
) | |
func enviarEmail(m string) { | |
auth := smtp.PlainAuth("", | |
"mail", | |
"senha", | |
"smtp.gmail.com", | |
) | |
smtp.SendMail("smtp.gmail.com:587", | |
auth, | |
"mail@gmail.com", | |
[]string{"mail@gmail.com"}, | |
[]byte(m), | |
) | |
fmt.Printf("email %s enviado com sucesso", m) | |
} | |
func main() { | |
fmt.Println("insira a mensagem do email") | |
var m string | |
fmt.Scanln(&m) | |
go enviarEmail(m) | |
fmt.Println("foi solicitado o envio do email, mas continuaremos com nosso programa ;)") | |
fmt.Scanln(&m) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment