php - "The sender hasn' t 已使用 sendgrid 验证此消息”

标签 php authentication email sendgrid

我正在使用 sendgrid 向创建新帐户的用户发送验证电子邮件,当通过向自己发送电子邮件来测试这一点时,它最终会出现在垃圾邮件文件夹中,并显示消息“发件人尚未验证此消息” 。我怎样才能解决这个问题?我使用 cURL 方法。

代码:

        $token = $this->token;
        
        $username = htmlspecialchars($this->username);

        // send an email to the user
        $email = new \SendGrid\Mail\Mail(); 
        $email->setFrom("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f5869a98909a9b90b5908d9498859990db969a98" rel="noreferrer noopener nofollow">[email protected]</a>", "John Doe");
        $email->setSubject("Verifictation email");
        $email->addTo($this->email, $this->username);
        $email->addContent("text/plain", "Hi $username! Please activate your email. Here is the activation link http://localhost/php/eindwerk/verification.php?token=$token");
        $email->addContent(
            "text/html", "Hi $username! Please activate your email. <strong>Here is the activation link:</strong> http://localhost/php/eindwerk/verification.php?token=$token"
        );

        $sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
        
        try {
            $response = $sendgrid->send($email);
        } catch (Exception $e) {
            echo 'Caught exception: '. $e->getMessage() ."\n";
        }

最佳答案

您无法在客户端中修复它。问题在于如何在 SendGrid 上设置帐户。如果您自己没有 sendgrid 帐户的管理员访问权限,则需要找到具有该权限的人。

以帐户管理员身份登录 sendgrid 帐户后,在左侧导航面板中打开“设置”,然后选择“发件人身份验证”:

enter image description here

从那里您可以验证源域(使用 SPF 和/或 DMARC)和/或验证各个发送帐户:

enter image description here

关于php - "The sender hasn' t 已使用 sendgrid 验证此消息”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75918564/

相关文章:

php - 使用 PHP 连接到 MySQL 的问题

php - 适用于 PHP 5.2 的 CodeIgniter 的 PHP ORM

c# - 安全登录表格和注册表(带序列号)

spring - 使用 Spring Security 3.0.2 进行 OpenId 身份验证和自动注册

email - 如何从openshift服务器内部通过gmail-account使用javamail发送电子邮件?

php - 发布到 Facebook(粉丝)页面墙

PHP Redis 销毁所有服务器上的 session

php - 使用 cURL 登录到特定的 WordPress 页面

c# - 为什么不更新 CommandParameter?

java - 使用 Java 中的正则表达式验证电子邮件