当前位置: > > > > golang 中与已验证的发件人身份不匹配错误
来源:stackoverflow
2024-04-24 23:45:34
0浏览
收藏
哈喽!今天心血来潮给大家带来了《golang 中与已验证的发件人身份不匹配错误》,想必大家应该对Golang都不陌生吧,那么阅读本文就都不会很困难,以下内容主要涉及到,若是你正在学习Golang,千万别错过这篇文章~希望能帮助到你!
问题内容
我正在处理用户注册时发送的电子邮件。我正在免费使用新的 sendgrid 帐户,但是当我运行我的函数时,它会向我显示以下错误,任何人都可以告诉我如何解决它。下面是我的 golang 函数
func sendotpmail(otp string) (err error) { from := mail.newemail("test", "[email protected]") subject := "comfirmation mail" to := mail.newemail("puneet", "[email protected]") // plaintextcontent := "" htmlcontent := "your confirmation otp is = " + otp message := mail.newsingleemail(from, subject, to, " ", htmlcontent) // ("" = plaintextcontent) client := sendgrid.newsendclient("api_key") response, err := client.send(message) fmt.println(response) fmt.println(err) return err }
作为响应,它将返回以下控制台输出:
&{403 {"errors":[{"message":"The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements","field":"from","help":null}]} map[Access-Control-Allow-Headers:[Authorization, Content-Type, On-behalf-of, x-sg-elas-acl] Access-Control-Allow-Methods:[POST] Access-Control-Allow-Origin:[https://sendgrid.api-docs.io] Access-Control-Max-Age:[600] Connection:[keep-alive] Content-Length:[281] Content-Type:[application/json] Date:[Sat, 25 Apr 2020 12:56:25 GMT] Server:[nginx] X-No-Cors-Reason:[https://sendgrid.com/docs/Classroom/Basics/API/cors.html]]}
我也在 2019 年实现了同样的功能,然后它可以工作,但现在我想更改它,然后这向我显示了这个错误。请帮我解决这个问题。
解决方案
由于这是 sendgrid 创建的新设置,旨在保护您的发送声誉并维护合法的发送行为,因此它们要求客户验证其发件人身份。由于这些旧的 sendgrid 帐户不会受到影响,因此 2020 年 4 月 6 日之后创建的帐户将能够进行发件人验证。
查看此文档以获取信息 –
理论要掌握,实操不能落!以上关于《golang 中与已验证的发件人身份不匹配错误》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注公众号吧!