c# mailgun 发送邮件测试

1、 登录  mailgun 官网注册账号,并激活账号。

2、登录账号后进入查看 domain 


上面的即是 mailgun默认给予免费测试的domain。

3、点击 domain name 查看域名信息,注意发邮件要用到



4、测试要发送的邮箱,必须要把 邮箱地址添加上mailgun中的 Authorized Recipients 中否则会提示:"Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings."

具体设置方法 点击 mailgun的 Account Settings 把要测试的邮件添加到 Recipients 中


5、实现代码 mailgun 中有(示例)

 public static IRestResponse SendSimpleMessage()
        {
            RestClient client = new RestClient();
            client.BaseUrl = new Uri("https://api.mailgun.net/v3");
            client.Authenticator =
                new HttpBasicAuthenticator("api",
                                            "key-f6dd9wewe32d2223345026e3d0423968a18ecb37ad1");
            RestRequest request = new RestRequest();
            request.AddParameter("domain", "sandbox757cf4babd96473098b300705a243434.mailgun.org", ParameterType.UrlSegment);
            request.Resource = "{domain}/messages";
            request.AddParameter("from", "postmaster@sandbox757cf4babd96473098b300705a243434.mailgun.org");
            request.AddParameter("to", "1787940846@qq.com");
            request.AddParameter("subject", "Hello");
            request.AddParameter("text", "Testing some Mailgun awesomness!");
            request.Method = Method.POST;
            return client.Execute(request);
        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值