admin管理员组文章数量:1559740
采用以下代码
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(,2); try { mail.To = "收件人邮箱"; mail.From = "发件人邮箱"; mail.Subject = "subject"; mail.BodyFormat = System.Web.Mail.MailFormat.Html; mail.Body = "<font color='red'>body</font>"; mail.Fields.Add("http://schemas.microsoft/cdo/configuration/smtpauthenticate", "1"); //basic authentication mail.Fields.Add("http://schemas.microsoft/cdo/configuration/sendusername", "发件人邮箱"); //set your username here mail.Fields.Add("http://schemas.microsoft/cdo/configuration/sendpassword", "发件人邮箱密码"); //set your password here mail.Fields.Add("http://schemas.microsoft/cdo/configuration/smtpserverport", 465);//set port mail.Fields.Add("http://schemas.microsoft/cdo/configuration/smtpusessl", "true");//set is ssl System.Web.Mail.SmtpMail.SmtpServer = "smtp.qq"; System.Web.Mail.SmtpMail.Send(mail,2); //return true; } catch (Exception ex) { ex.ToString(,2); }
以下内容转于
System.mail 腾讯ssl发送邮件超时
2014-05-10 10:12:38 3994浏览我采用了 的自带组件 System.Web.Mail.MailMessage发送邮件,主要是在客户注册网站成功的时候发条欢迎邮件,最近邮件无法发送了,看了下腾讯smtp邮件配置,所有的邮件发送都换成ssl了,之前用的是25端口,现在换成了465或587,于是修改代码如下:
MailMessage msgMail = new MailMessage("发件箱", "收件箱", "邮件标题", "邮件内容",2); SmtpClient smtp = new SmtpClient("smtp.qq", 465,2); smtp.EnableSsl = true; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Credentials = new System.Net.NetworkCredential("发件箱", "发件箱登录密码",2); try { smtp.Send(msgMail,2); } catch (Exception ex) { Console.WriteLine("发送完毕......",2); }
这样还是不行,报操作已超时错误在国外的技术网站上看到一句话System.Net.Mail支持Explicit SSL但是不支持Implicit SSL,然后查了下关于这两个模式的资料,我按照我理解的说一下:
Explicit SSL 发起于未加密的25,然后进行一个starttl握手,最终切换到加密的连接。
Implicit SSL 直接从指定的端口发起starttl握手。
既然指定了端口,那么应该就是使用了Implicit SSL,不知道微软什么时候能更新下System.mail,System.mail能在邮件中嵌入图片的。问题到了这里,那是不是就没有办法利用腾讯邮箱发邮件了呢?答案肯定是否定的,foxmail不就可以配置发送邮件吗?我们可以利用CDO.Message和System.web.mail发送邮件。
详见我下面的2篇文章:
C#利用CDO.Message发送邮件
C#利用System.web.mail发送邮件
http://www.codingwhy/view/616.html
http://www.codingwhy/view/611.html
版权声明:本文标题:使用QQ企业邮箱465端口发送邮件失败 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1727423828a1113864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论