sending mails using standard lib

This commit is contained in:
vinchent 2024-07-16 13:35:10 +02:00
parent 998850b708
commit bf61fb7c18

View File

@ -4,6 +4,7 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"log" "log"
"net/smtp"
"os" "os"
_ "github.com/jackc/pgx/v5/stdlib" _ "github.com/jackc/pgx/v5/stdlib"
@ -17,6 +18,11 @@ func main() {
} }
defer conn.Close() defer conn.Close()
// Send test email
from := "me@here.com"
auth := smtp.PlainAuth("", from, "", "localhost")
_ = smtp.SendMail("localhost:1025", auth, from, []string{"you@there.com"}, []byte("Hello world"))
log.Println("Connected to database!") log.Println("Connected to database!")
// test my connection // test my connection