dongzi1209 2018-09-29 04:42
浏览 620

如何使用带有端口587的Amazon SMTP发送电子邮件

I want to send email using Amazon SMTP.

I am using the example

https://gist.github.com/jim3ma/b5c9edeac77ac92157f8f8affa290f45

but is not working !

I got this message error:

tls: first record does not look like a TLS handshake panic: tls: first record does not look like a TLS handshake

  • 写回答

1条回答 默认 最新

  • dongpiao9078 2018-09-30 08:44
    关注

    Try to use the code from https://golang.org/pkg/net/smtp/#example_SendMail

    package main
    
    import (
        "log"
        "net/smtp"
    )
    
    func main() {
        // Set up authentication information.
        auth := smtp.PlainAuth("", "user@example.com", "password", "mail.example.com")
    
        // Connect to the server, authenticate, set the sender and recipient,
        // and send the email all in one step.
        to := []string{"recipient@example.net"}
        msg := []byte("To: recipient@example.net
    " +
            "Subject: discount Gophers!
    " +
            "
    " +
            "This is the email body.
    ")
        err := smtp.SendMail("mail.example.com:25", auth, "sender@example.org", to, msg)
        if err != nil {
            log.Fatal(err)
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集