You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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 text was updated successfully, but these errors were encountered:
mikioh
changed the title
net/smtp package document does not explain how to add subject and body in msg parameter
net/smtp: package document does not explain how to add subject and body in msg parameter
Feb 5, 2015
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 text was updated successfully, but these errors were encountered: