In. Net, use SendGrid Web Api to send emails (with source code) and sendgridapi
SendGridIt is a third-party provider for mail sending services and is widely used abroad. Similar services in China are SendCloud.
SendGridThere are two ways to send emails. One isSMTP API, One isWeb Api.SMTP APIIt is a relatively simple method. As long as we have prepared the Mail Message and sent it directly to the SendGrid Mail server, the SendGrid Mail server will deliver it for us. The other method is Web Api.
Generally, many third-party server providers prohibit external port 25 connections, so you cannot connect to the SendGrid SMTP server to send emails. In this case, Web API is a good choice. SengGrid official has more detailed smtp api Demo. Demo address is https://github.com/sendgrid/sendgrid-csharp because there is no Web API Demo, their own time to write a copy, now share out the https://github.com/justrun1983/sendgrid-csharp-webapi
Used in the codeRestSharp, A very convenient access in. NetRestful API. The complete email sending code is as follows, including cc, bcc, and attachments.
public class WebApiRestSharp { private const string ApiWebSite = "https://sendgrid.com"; private const string ApiUrlAddress = "api/mail.send.json"; public static void SendNormalHelloWorldEmail() { var client = new RestClient(ApiWebSite); var request = new RestRequest(ApiUrlAddress, Method.POST); request.AddParameter("api_user", Config.SendGridName); request.AddParameter("api_key", Config.SendGridPassword); request.AddParameter("to[]", Config.ToEmail); request.AddParameter("cc[]", Config.ToEmail); request.AddParameter("bcc[]", Config.ToEmail); request.AddParameter("subject", "Test"); request.AddParameter("from", "test@test.me"); request.AddParameter("text", "HelloWorld1"); request.AddFile("files[2.txt]", @"C:\1.txt"); // execute the request var response = client.Execute(request); var content = response.Content; // raw content as string } }
PHP uses SendGrid to send emails, and the code they send officially cannot be sent.
What are the prompts? Generally, there is SSL verification, and the verification is removed.
If you know the webconfig file, you can download the website source code.
No ~