Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/smtp: package document does not explain how to add subject and body in msg parameter #9776

Closed
Jiran opened this issue Feb 5, 2015 · 2 comments

Comments

@Jiran
Copy link

Jiran commented 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)
}

@mikioh 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
@minux
Copy link
Member

minux commented Feb 5, 2015

This is standard SMTP behavior.

Do you want to add an example to the net/smtp package? Please feel free.
See https://golang.org/doc/contribute.html for the procedure.

@bradfitz bradfitz added this to the Go1.5 milestone Feb 7, 2015
@bradfitz bradfitz self-assigned this Feb 7, 2015
@bradfitz
Copy link
Contributor

bradfitz commented Feb 7, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants