SendGrid sends emails with the "on behalf of" or "via sendgrid.net" appear in your emails to your customers instead of showing your domain if your domain is not whitelisted.
To fix this, you need to set up specific SPF/DKIM entries in your DNS configuration. With an authenticated domain, you can remove the "via" or "sent on behalf of" message. You can swap sendgrid.net with your own personalized sending domain after authenticating a domain. You'll need to create a subdomain so SendGrid can create the DNS records, and later you'll need to provide them to your host provider.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php // Uncomment next line if you're not using a dependency loader (such as Composer) // require_once '<PATH TO>/sendgrid-php.php'; $apiKey = getenv('SENDGRID_API_KEY'); $sg = new SendGrid($apiKey, ["impersonateSubuser" => "The subuser's username. This header generates the API call as if the subuser account was making the call."]); $request_body = json_decode('{ "domain": "example.com", "subdomain": "news", "username": "john@example.com", "ips": [ "192.168.1.1", "192.168.1.2" ], "custom_spf": true, "default": true, "automatic_security": false }'); try {$response = $sg->client->whitelabel()->domains()->post($request_body);print $response->statusCode() . " ";print_r($response->headers());print $response->body() . " "; } catch (Exception $ex) {echo 'Caught exception: '. $ex->getMessage(); }
View all errors
Send up to 10,000 notifications every month, for free.
Get started for free
Send up to 10,000 notifications every month, for free.
Get started for free
© 2024 Courier. All rights reserved.