2013-12-12 06:27:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/smtp"
|
|
|
|
)
|
|
|
|
|
2013-12-12 07:00:22 +00:00
|
|
|
//Send sends an Email using a connection to Server.
|
|
|
|
//If a Username and Password are set for the Server, authentication will be attempted
|
|
|
|
//However, to support open-relays, authentication is optional.
|
2013-12-12 06:27:43 +00:00
|
|
|
func Send(email Email, server Server) {
|
2013-12-12 07:00:22 +00:00
|
|
|
auth := nil
|
|
|
|
if server.User != nil && server.Password != nil {
|
|
|
|
auth := smtp.PlainAuth("", server.User, server.Password, server.Host)
|
|
|
|
}
|
|
|
|
smtp.SendMail(server.Host, auth, email.From, email.To, Email.Body)
|
2013-12-12 06:27:43 +00:00
|
|
|
}
|