简体   繁体   中英

Sending emails as company domain from SendGrid

I own a domain, example.com. I'd like to send out emails from my webapp where it displays it's from info@example.com , or support@example.com .

I've used SendGrid a lot in the past from within my websites, but I've always simply been able to fill out where an email is from by editing the From property of the SendGridMessage class, and it just showed up that way on clients.

Is there an official way/API from sendgrid to utilize a domain that I own? What's to stop me or someone else from typing any domain they want using the sendgrid API?

The process of setting up DNS records for your domain that allow your emails to be authenticated, as well as verifying your ownership of the domains, is known at SendGrid as whitelabeling . After this process, SPF and DKIM records will then be available for receiving servers to check.

SPF and DKIM ensure the originating IP is allowed to send email on behalf of the domain in question, and to essentially verify that the contents of the email have not been tampered with respectively.

The thing that will stop others from sending from your domain is called DMARC . Domains owned by yahoo, aol, and very soon google all implement strict policies; emails claiming to be from these domains but that are not will never be delivered. Many other domains will soon be following this trend and implementing DMARC.

The code sample from https://azure.microsoft.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/ shows how to do this:

// Create the email object first, then add the properties.
var myMessage = new SendGridMessage();

// Add the message properties.
myMessage.From = new MailAddress("john@example.com");

// Add multiple addresses to the To field.
List<String> recipients = new List<String>
{
    @"Jeff Smith <jeff@example.com>",
    @"Anna Lidman <anna@example.com>",
    @"Peter Saddow <peter@example.com>"
};

myMessage.AddTo(recipients);

myMessage.Subject = "Testing the SendGrid Library";

//Add the HTML and Text bodies
myMessage.Html = "<p>Hello World!</p>";
myMessage.Text = "Hello World plain text!";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM