-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
readme: drop unencrypted client example
We don't want to encourage people to turn TLS off.
- Loading branch information
Showing
1 changed file
with
1 addition
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,40 +45,7 @@ func main() { | |
} | ||
``` | ||
|
||
If you need more control, you can use `Client` instead. For example, if you | ||
want to send an email via a server without TLS or auth support, you can do | ||
something like this: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"log" | ||
"strings" | ||
|
||
"github.com/emersion/go-smtp" | ||
) | ||
|
||
func main() { | ||
// Setup an unencrypted connection to a local mail server. | ||
c, err := smtp.Dial("localhost:25") | ||
if err != nil { | ||
return err | ||
} | ||
defer c.Close() | ||
|
||
// Set the sender and recipient, and send the email all in one step. | ||
to := []string{"[email protected]"} | ||
msg := strings.NewReader("To: [email protected]\r\n" + | ||
"Subject: discount Gophers!\r\n" + | ||
"\r\n" + | ||
"This is the email body.\r\n") | ||
err := c.SendMail("[email protected]", to, msg) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
``` | ||
If you need more control, you can use `Client` instead. | ||
|
||
### Server | ||
|
||
|