I usually use free domain name mailboxes to send verification code emails, but sometimes I can’t send them when I send too many emails. I heard that using sendcloud can avoid it, and it can also prevent Alibaba Cloud emails from sending QQ mailboxes into the trash, so I went to register. There are only 50 free account numbers per month, so you can play by yourself. .
If the fee is 59.1 million a month, I don't know if it will work. . Check it out first. .
The following is the packaged code, the api_user and api_key can be set in the webpage
/*
* SendMailBySendCloud
* Function: use SendCloud to send mail
* Return value: string, return value in JSON format, or exception
* Parameters:
* from - the displayed sender's email address
* to - the recipient's email address
* title - the email title
* content - message content
*/
public static string SendMailBySendCloud(String from, String to, String title, String content, string api_user = "niuna?????", string api_key = "v2?????")
{
String url = "http://api.sendcloud.net/apiv2/mail/send";
HttpClient client = null;
HttpResponseMessage response = null;
string result;
try
{
client = new HttpClient();
List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>();
paramList.Add(new KeyValuePair<string, string>("apiUser", api_user));
paramList.Add(new KeyValuePair<string, string>("apiKey", api_key));
paramList.Add(new KeyValuePair<string, string>("from", from));
paramList.Add(new KeyValuePair<string, string>("fromName", from));
paramList.Add(new KeyValuePair<string, string>("to", to));
paramList.Add(new KeyValuePair<string, string>("subject", title));
paramList.Add(new KeyValuePair<string,string>("html", content));
response = client.PostAsync(url, new FormUrlEncodedContent(paramList)).Result;
result = response.Content.ReadAsStringAsync().Result;
//Console.WriteLine(result);
}
catch (Exception e)
{
result = e.Message;
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ", e.Message);
}
finally
{
if (null != client)
{
client.Dispose();
}
}
return result;
}