本文介绍了SMTP错误:535 5.7.8 Go中的gmail不接受用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此功能测试来自本地主机的应用的传出电子邮件:

I'm trying to test an app's outgoing emails from localhost using this function:

func SendContactUsForm(subject, email, body string) error {
    var err error
    from := "[email protected]"
    pass := "somecrazypw"
    to := "[email protected]"
    msg := "From: " + from + "\n" +
    "To: " + to + "\n" +
    "Subject: Contact form:" + subject + "\n" + body
    err = smtp.SendMail("smtp.gmail.com:587",
        smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
        from, []string{to}, []byte(msg))
    if err != nil {
        log.Printf("smtp error: %s", err)
        return err
    }
    return nil
}

但我收到此错误:

尽管 [email protected] 的凭据是正确的,并且我启用了 Allow安全性较低的应用程序 [email protected] 上。

Despite the fact that the credentials of [email protected] are correct and I have enabled Allow less secure apps on [email protected].

那么这里可能出什么问题了?以及我该如何解决?

So what could be wrong here? And how can I fix it?

推荐答案

从并使用该密码。

更多如何生成一个!

这篇关于SMTP错误:535 5.7.8 Go中的gmail不接受用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 01:34