email - 如何解决从网站发送的电子邮件中的可疑链接错误

标签 email go https smtp google-workspace

我正在从我的 Go RESTFUL 网络服务向我们的用户发送一封重设密码的电子邮件,我正在使用 Go SMTP 和 google Gsuite 域,info@mycompanyname.ca!我之前测试过它并且它有效,但是当我将它发送给我们的一位用户时,他收到了可疑链接错误。他正在使用 Gmail 网站。我检查了 https,我的网站和链接都是 https,当他将电子邮件转发给我时,我再也看不到这个错误了!有人可以帮我解决这个问题吗?

这是我的代码:

        mime string = "MIME-version: 1.0;\nContent-Type: text/html; 
        charset=\"UTF-8\";\n\n"
        hostname string = "smtp.gmail.com"

        auth := smtp.PlainAuth("", username, password, hostname)

        data := map[string]string{"Token": token}
        buffer := new(bytes.Buffer)

        t, err := template.ParseFiles(htmlFilename)
        if err != nil {
                return err 
        }   

        err = t.Execute(buffer, data)
        if err != nil {
                return err 
        }   

        msg := []byte(subject + mime + buffer.String())
        reciever = append(reciever, clientMail)

        return smtp.SendMail(hostname+":587", auth, "", reciever, msg)
}

这是 HTML:

  <!DOCTYPE html>
    <html lang="en">
    <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1.0, shrink-to-fit=no" name="viewport">
    <meta name="author" content="some name">
    <meta name="description" content="Entry HTML page for the dashboard">
    </head>
    <body style="max-width: 50rem; margin: auto; margin-top: 1rem;">
    <img src="https://address in google drive" style="margin:auto;
    display: block; width: 17rem; height: 4.6rem; position: relative; left: 50%; transform: translateX(-50%);"
    alt="logo" title="company logo" />
    <div style="margin-top: 0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-top: 1px solid lightgray;
    border-bottom: 1px solid lightgray; background-color: #f9f9f9">
    <h3>Hello!</h3>
    <p>You receive this email because this is your first time logging in. To enter your account,
    you will need to set a password. Click the button below to set it.</p>
    <div style="text-align: center">
    <a href="https://websiteAddress/#/changepasswordapi?token={{ .Token }}" target="_blank">
    <button style="cursor: pointer; border: none; width: 50%; background-color: #ED5E28;
    color: white; font-size: 1rem; height: 2.5rem;
    border-radius: 0.35rem"><strong>Set Password</strong></button>
    </a>
    </div>
    <p>If you didn't request this, please ignore this email. The password setup is only valid for the next 24 hours.</p>
    <p>Thanks,</p>
    <p>compaynName Team</p>
    </div>
    <div style="text-align: center; font-size: 0.8rem; color: gray">
    <p>&copy; 2019 companyName. All rights reserved.</p>
    <p>company addr</p>
    <P>company city</P>
    </div>
    </body>
    </html>

最佳答案

好的,我解决了这个问题。起初,我认为这可能是 G Suite 的问题,所以我调用他们,我意识到这不是因为我可以在收件箱中看到我们的电子邮件,而不是在垃圾邮件文件夹中。所以我尝试了 this link我请求对我们的域进行审查。大约 30 小时后,问题消失了!

关于email - 如何解决从网站发送的电子邮件中的可疑链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54315514/

相关文章:

go - 如何在 travis-ci 上管理构建 golang 项目

html - 如何使带有 HTTPS iframe 的页面看起来安全

spring - Http 到 Https AWS Elasticbeanstalk

c# - 将 ASP.NET MVC View 返回为 HTML 文件,以便在电子邮件模板中使用

java - 如何将 PST 文件中的所有或选定的电子邮件和电子邮件附件提取到本地文件夹中?

Android:将图像添加到电子邮件的撰写正文

wcf - 在 IIS 中托管时,使用 HTTPS 进行 Webhttpbinding 和使用 UserNamepPasswordValidator 进行身份验证

linux - 使用 bash 脚本发送邮件

logging - 如何将自定义(非 const)字符串信息添加到日志格式?

go - 关于 $GOPATH 的一些问题