发送邮件出错
完整报错信息如下
2022-02-17 15:21:46 DEBUG verifycode/verifycode.go:102 验证码 {"生成验证码": "{\"summer@example.com\":\"123456\"}"}
2022-02-17 15:21:46 DEBUG mail/driver_smtp.go:27 发送邮件 {"发件详情": "{\"ReplyTo\":null,\"From\":\" \\u003c\\u003e\",\"To\":[\"summer@example.com\"],\"Bcc\":null,\"Cc\":null,\"Subject\":\"Email 验证码\",\"Text\":null,\"HTML\":\"PGgxPuaCqOeahCBFbWFpbCDpqozor4HnoIHmmK8gMTIzNDU2IDwvaDE+\",\"Sender\":\"\",\"Headers\":{},\"Attachments\":null,\"ReadReceipt\":null}"}
2022-02-17 15:21:46 ERROR mail/driver_smtp.go:40 发送邮件 {"发件出错": "mail: invalid string"}
gohub/pkg/mail.(*SMTP).Send
E:/Go/src/github.com/stringer/gohub/pkg/mail/driver_smtp.go:40
gohub/pkg/mail.(*Mailer).Send
E:/Go/src/github.com/stringer/gohub/pkg/mail/mail.go:43
gohub/pkg/verifycode.(*VerifyCode).SendEmail
E:/Go/src/github.com/stringer/gohub/pkg/verifycode/verifycode.go:70
gohub/app/http/controllers/api/v1/auth.(*VerifyCodeController).SendUsingEmail
E:/Go/src/github.com/stringer/gohub/app/http/controllers/api/v1/auth/verify_code_controller.go:60
github.com/gin-gonic/gin.(*Context).Next
E:/Go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168
gohub/app/http/middlewares.Recovery.func1
E:/Go/src/github.com/stringer/gohub/app/http/middlewares/recovery.go:60
github.com/gin-gonic/gin.(*Context).Next
E:/Go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168
gohub/app/http/middlewares.Logger.func1
E:/Go/src/github.com/stringer/gohub/app/http/middlewares/logger.go:45
github.com/gin-gonic/gin.(*Context).Next
E:/Go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
E:/Go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/gin.go:555
github.com/gin-gonic/gin.(*Engine).ServeHTTP
E:/Go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/gin.go:511
net/http.serverHandler.ServeHTTP
F:/GoLang/src/net/http/server.go:2879
net/http.(*conn).serve
F:/GoLang/src/net/http/server.go:1930
2022-02-17 15:21:46 DEBUG middlewares/logger.go:75 HTTP Access Log {"status": 200, "request": "POST /v1/auth/verify-codes/email", "query": "", "ip": "::1", "user-agent": "PostmanRuntime/7.29.0", "errors": "", "time": "6.843ms", "Request Body": "{\r\n \"email\": \"summer@example.com\",\r\n \"captcha_id\": \"captcha_skip_test\",\r\n \"captcha_answer\": \"123456\"\r\n}", "Response Body": "{\"message\":\"操作成功\",\"success\":true}"}
环境:Win
出错之后,代码完全复制 7.6
,7.7
教程的,还是一样的报错
安装完 Mailhog
不能直接启动,是使用完路径启动的:
$ $GOPATH/bin/MailHog.exe
2022/02/17 15:25:38 Using in-memory storage
2022/02/17 15:25:38 [SMTP] Binding to address: 0.0.0.0:1025
[HTTP] Binding to address: 0.0.0.0:8025
2022/02/17 15:25:38 Serving under http://0.0.0.0:8025/
Creating API v1 with WebPath:
Creating API v2 with WebPath:
想问下报错信息 mail: invalid string
是指哪个无效呢?
用这个方法来调试一下 1.7. 利用源码来排错《G02 Go API 实战》