static readonly string smtpServer = System.Configuration.ConfigurationManager.AppSettings["SmtpServer"];
static readonly string userName = System.Configuration.ConfigurationManager.AppSettings["UserName"];
static readonly string pwd = System.Configuration.ConfigurationManager.AppSettings["Pwd"];
static readonly int smtpPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpPort"]);
static readonly string authorName = System.Configuration.ConfigurationManager.AppSettings["AuthorName"];
protected void Page_Load(object sender, EventArgs e)
{
MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add("1833793557@qq.com"); msg.From = new MailAddress(userName, authorName, System.Text.Encoding.UTF8);
/* 上面3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/
msg.Subject = "这是测试邮件";//邮件标题
msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码
msg.Body = "邮件内容";//邮件内容
msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
msg.IsBodyHtml = false;//是否是HTML邮件
msg.Priority = MailPriority.High;//邮件优先级 SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(userName, pwd); client.Port = ;
client.Host = smtpServer;
client.EnableSsl = true; //经过ssl加密
object userState = msg; //异步发送
client.SendAsync(msg, userState);
//同步发送
//client.Send(msg);
}

C#发送邮件(使用SSL,587端口)的更多相关文章

  1. python发送邮件脚本ssl 465端口

    #coding:utf8 from smtplib import SMTP_SSL from email.header import Header from email.mime.text impor ...

  2. sendEmail 阿里云使用587端口

    使用sendEmail使用参数   -o tls=yes -s smtp服务器+端口 因为阿里云屏蔽了25端口,我使用465也不成功,只有使用587端口,我使用的qq企业邮箱,测试可用

  3. [转载]Linux上使用ssl进行端口转发

    原文地址:Linux上使用ssl进行端口转发 作者:呼延十 背景介绍 作为一个后端程序员,经常要和别人联调接口,每当这时,总是被公司的各种,dev,qa,pre,prod环境搞得头疼,,,我真的只是想 ...

  4. SpringMvc使用JavaMail发送邮件,并使用465端口开启ssl加密传输,保证邮件安全

    代码在本地发邮件没任何问题.但部署到服务器,发送邮件显示连接异常.一开始非常懵逼,之后telnet smtp.163.com 25不通,发现是云服务器出于安全考虑,关闭了服务器的25端口,而25端口是 ...

  5. 阿里云服务器发送邮件失败,25端口被禁用,采用ssl 方式 465端口发送

    /** * 邮件工具类 * User: NZG * Date: 2019/3/8 * Time: 12:25 **/ @Data @Component @Configuration @Configur ...

  6. Java Mail 发送邮件(SSL加密方式,TSL加密方式)

    一.一般配置 发送邮件需要用到  mail包 maven 依赖如下: <!-- https://mvnrepository.com/artifact/javax.mail/mail --> ...

  7. SSL默认端口时,用http://ip:port/访问出错(转)

    add by zhj: 其实就是保证https访问的port与服务器监听的port是同一port 原文:http://blog.csdn.net/ikmb/article/details/386370 ...

  8. 关于net mail组件ssl端口问题

    最近开发一个项目使用到.net mail组件发送邮件.在开发环境中一切正常,可是部署到阿里云服务器上死活发送不出去,一直连接不上,或者报语法错误. 然后是各种折腾,各种测试,最后发现,使用ssl的时候 ...

  9. Spring Boot 使用465端口发送邮件

    2017年10月27日 15:04:24 伊宇紫 阅读数:2710 标签: 465端口邮件springboot 更多 个人分类: Java   版权声明:本文为博主原创文章,未经博主允许不得转载. h ...

随机推荐

  1. 将jar包安装到maven仓库

    <!-- https://mvnrepository.com/artifact/ojdbc/ojdbc --><!-- (参数一):下载到本地的ojdbc-10.2.0.4.0.ja ...

  2. django-model的元类Meta

    Meta类存在model类里面 模型元选项 文档有更多Meta类的配置属性: English:https://docs.djangoproject.com/en/1.11/ref/models/opt ...

  3. http协议再复习(二)

    HTTP和HTTPS HTTP协议(HyperText Transfer Protocol,超文本传输协议):是一种发布和接收 HTML页面的方法. HTTPS(Hypertext Transfer ...

  4. IIS 禁止访问:在 Web 服务器上已拒绝目录列表

    webconfig <configuration> <system.webServer> <directoryBrowse enabled="true" ...

  5. eclipse liquibase 插件

    http://marketplace.eclipse.org/category/free-tagging/liquibase http://marketplace.eclipse.org/market ...

  6. 拦截TextBox 双击消息

    Option Explicit Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLo ...

  7. 14.Longest Common Prefix (String)

    Write a function to find the longest common prefix string amongst an array of strings. class Solutio ...

  8. DropDownList控件的使用方法

    1. 使用代码添加数据 <asp:DropDownList ID="DropDownList1" runat="server"> </asp: ...

  9. [leetcode]621. Task Scheduler任务调度

    Given a char array representing tasks CPU need to do. It contains capital letters A to Z where diffe ...

  10. 8-@Pointcut( "execution(* com.ctgu.controller.AccountController.transfer(..))" ) 拦截配置问题

    @pointcut()可以直接指定到某个包下的某个类的某个方法上: