Help us understand the problem. What is going on with this article?

Go: Starttls でメールの送信

こちらと同じことを Deno で行いました。
Python3: Starttls でメールの送信
hi-ho.ne.jp で試しました。

hi-ho.go
// ---------------------------------------------------------------
//
//  hi-ho.go
//
//                  Jul/07/2020
// ---------------------------------------------------------------
package main

import (
    "fmt"
    "os"
    "net/smtp"
    "github.com/joho/godotenv"
)


func main() {

    fmt.Fprintf (os.Stderr,"*** 開始 ***\n")

err := godotenv.Load(".env")
    if err != nil {
        panic(err)
    }

    server := os.Getenv("SERVER")
    port := os.Getenv("PORT")
    usr := os.Getenv("USR")
    password := os.Getenv("PASSWORD")

    fmt.Fprintf (os.Stderr,server + "\n")
    fmt.Fprintf (os.Stderr,port + "\n")

    from := os.Getenv("FROM")
    to := os.Getenv("TO")

    auth := smtp.PlainAuth("", usr, password, server)

    msg := []byte("" +
        "From: " + from + "\n" +
        "To: " + to + "\n" +
        "Subject: Test from Hi-ho PM 20:02\n" +
        "\n" +
        "テスト\n" +
        "今晩は。\n" +
        "PM 20:02\n" +
    "")

    err = smtp.SendMail(server + ":" + port, auth, from, []string{to}, msg)
    if err != nil {
        fmt.Fprintf(os.Stderr, "エラー: %v\n", err)
        return
    }

    fmt.Print("success\n")

    fmt.Fprintf (os.Stderr,"*** 終了 ***\n")
}

// ---------------------------------------------------------------
.env
SERVER = 'hi-ho.mose-mail.jp'
PORT = 587
USR = '****@hi-ho.ne.jp'
PASSWORD = '****'
FROM = '****@hi-ho.ne.jp'
TO = 'sample@example.com'

実行結果

$ go run hi-ho.go
*** 開始 ***
hi-ho.mose-mail.jp
587
success
*** 終了 ***
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away