The net/smtp package document does not mention how to add subject and body for emails sent. http://golang.org/pkg/net/smtp/#SendMail
Here is an example of one way to have both subject and body text -
auth := smtp.PlainAuth(
"",
"email@example.com",
"password",
"smtp.example.com",
)
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step
// The Byte array provides both Subject and body
err := smtp.SendMail(
"smtp.example.com:587",
auth,
"me@example.com",
[]string{recipient@example.com},
[]byte("Subject: Test Subject Text \r\n\r\n Test Email Body Text"),
)
if err != nil {
fmt.Println("Email Error: ", err)
}
The net/smtp package document does not mention how to add subject and body for emails sent. http://golang.org/pkg/net/smtp/#SendMail
Here is an example of one way to have both subject and body text -
auth := smtp.PlainAuth(
"",
"email@example.com",
"password",
"smtp.example.com",
)
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step
// The Byte array provides both Subject and body
err := smtp.SendMail(
"smtp.example.com:587",
auth,
"me@example.com",
[]string{recipient@example.com},
[]byte("Subject: Test Subject Text \r\n\r\n Test Email Body Text"),
)
if err != nil {
fmt.Println("Email Error: ", err)
}