用sendcloud来发邮件
平时发验证码邮件都是用免费域名邮箱,但是有时一频繁发多了就发不了了,听说用sendcloud可以避免,还能避免阿里云邮件发QQ邮箱进垃圾箱中,去注册了下,免费账户号每个月才50封,自己玩玩可以吧。。
收费的话一个月59,1万封以内的,不知道行不行。。先看看吧。。
下面是封装好的代码,那个api_user和api_key进网页里设置就好了
/*
* SendMailBySendCloud
* 功能:使用SendCloud发送邮件
* 返回值:string,JSON格式的返回值,或者异常
* 参数:
* from - 显示的发件人邮箱
* to - 收件人邮箱
* title - 邮件标题
* 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;
}
用sendcloud来发邮件的更多相关文章
- # PHP - 使用PHPMailer发邮件
PHPMailer支持多种邮件发送方式,使用起来非常简单 1.下载PHPMailer https://github.com/PHPMailer/PHPMailer,下载完成加压后, 把下边的两个文件复 ...
- Linux发邮件之mail命令
一.mail命令 1.配置 vim /etc/mail.rc 文件尾增加以下内容 set from=1968089885@qq.com smtp="smtp.qq.com" set ...
- 测试MailUtils,作用是发邮件
package cn.itcast.test; import java.io.IOException; import javax.mail.MessagingException; import jav ...
- SQL Server定时自动抓取耗时SQL并归档数据发邮件脚本分享
SQL Server定时自动抓取耗时SQL并归档数据发邮件脚本分享 第一步建库和建表 USE [master] GO CREATE DATABASE [MonitorElapsedHighSQL] G ...
- 学习linux之用mail命令发邮件
背景 这两天工作比较闲,网上各种冲浪(这个词暴露我的网龄了).看到一位大神的文章更闲 <>.端详一番,原来是用R语言拼接字符串后用shell命令发出去.发现shell命令既然还能直接发邮件 ...
- linux mail利用外部邮箱地址发邮件
mail命令发送邮件需要sendmail或postfix服务 三种常用格式发信 mail -s "标题" xxx@xxx.xxx #第一种方法,你可以把当前shell当成编辑器来用 ...
- 打电话,发短信,发邮件,app跳转
1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...
- iOS中如何切换到发短信、打电话、发邮件
我们在做APP的时候,难免会遇到需要调用短信,电话等程序的时候.如美团. 当然,这些都只是一些简单的方法就可以实现,但是时间久了也会淡忘,所以想写这边博客.一是为了再捡起来复习一下,另一个相当于留个备 ...
- 发邮件 和 excel导出中文文件名
/** * 发邮件 * @param email * @param subject * @param body * @throws UnsupportedEncodingException */ pu ...
随机推荐
- UI Automation的两个成熟的框架(QTP 和Selenium)
自己在google code中开源了自己一直以来做的两个自动化的框架,一个是针对QTP的一个是针对Selenium的,显而易见,一个是商业的UI automation工具,一个是开源的自动化工具. 只 ...
- 删除sql server用户时报15138错误
问题 在删除sql server中某数据库下的用户时报15138错误,见下图 解决 可用下述sql代码检查该用户的架构信息,然后逐一修正 SELECT s.name FROM sys.schemas ...
- urllib2特点--urllib2.build_opener对象接口
# -*- coding: cp936 -*- #python 27 #xiaodeng #urllib2特点--urllib2.build_opener对象接口 import urllib2 imp ...
- 什么是XML RPC?
# -*- coding: cp936 -*- #python 27 #xiaodeng #什么是XML RPC? #中文叫:远程过程调用 #使用http协议做传输协议的rpc机制,使用xml文本的方 ...
- python之函数用法endswith()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法endswith() #http://www.runoob.com/python/at ...
- DUBBO本地搭建及小案例 (转)
DUBBO的介绍部分我这里就不介绍了,大家可参考官方文档. DUBBO的注册中心安装 DUBBO的注册中心支持好几种,公司用到zookeeper注册中心,所以我这边只说明zookeeper注册中心如何 ...
- 【PHP采集】php采集、[\s\S]的使用、正则获取 换行字符串或html块
1.如图,我想要获取 红框框中的html内容,但是普通的正则一直获取不到: 2.原因剖析:因为html换行了,所以直接 /<h3 class=\"s_name\"(.+?)& ...
- empty、isset、is_null的比较
直接上代码 <?php $a=0; $b='0'; $c=0.0; $d=''; $e=NULL; $f=array(); $g='\0'; $h=' ';//space $i=true; $j ...
- 如何在 CentOS 7 中安装或升级最新的内核
虽然有些人使用 Linux 来表示整个操作系统,但要注意的是,严格地来说,Linux 只是个内核.另一方面,发行版是一个完整功能的系统,它建立在内核之上,具有各种各样的应用程序工具和库. 在正常操作期 ...
- Notes of O_DIRECT flag
What is O_DIRECT Starting with kernel 2.4, Linux allows an application to bypass the buffer cache wh ...