Created
September 13, 2014 19:42
-
-
Save ceb10n/6b9fcf85f3ea63cfdafe to your computer and use it in GitHub Desktop.
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, r chan string) { | |
auth := smtp.PlainAuth("", | |
"user", | |
"pass", | |
"smtp.gmail.com", | |
) | |
smtp.SendMail("smtp.gmail.com:587", | |
auth, | |
"mail", | |
[]string{"mail"}, | |
[]byte(m), | |
) | |
r <- "email enviado com sucesso" | |
} | |
func notificarEmail(r chan string) { | |
fmt.Println(<-r) | |
} | |
func main() { | |
fmt.Println("insira a mensagem do email") | |
var m string | |
fmt.Scanln(&m) | |
c := make(chan string) | |
go enviarEmail(m, c) | |
go notificarEmail(c) | |
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