使用QQ企业邮箱465端口发送邮件失败

阅读:875 2019-03-20 14:08:53 来源:新网

采用以下代码

system.web.mail.mailmessagemail=newsystem.web.mail.mailmessage(,2);try{mail.to="收件人邮箱";mail.from="发件人邮箱";mail.subject="subject";mail.bodyformat=system.web.mail.mailformat.html;mail.body="body";mail.fields.add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");//basicauthenticationmail.fields.add("http://schemas.microsoft.com/cdo/configuration/sendusername","发件人邮箱");//setyourusernameheremail.fields.add("http://schemas.microsoft.com/cdo/configuration/sendpassword","发件人邮箱密码");//setyourpasswordheremail.fields.add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",465);//setportmail.fields.add("http://schemas.microsoft.com/cdo/configuration/smtpusessl","true");//setissslsystem.web.mail.smtpmail.smtpserver="smtp.qq.com";system.web.mail.smtpmail.send(mail,2);//returntrue;}catch(exceptionex){ex.tostring(,2);}

我采用了.net的自带组件system.web.mail.mailmessage发送邮件,主要是在客户注册网站成功的时候发条欢迎邮件,最近邮件无法发送了,看了下腾讯smtp邮件配置,所有的邮件发送都换成ssl了,之前用的是25端口,现在换成了465或587,于是修改代码如下:

mailmessagemsgmail=newmailmessage("发件箱","收件箱","邮件标题","邮件内容",2);smtpclientsmtp=newsmtpclient("smtp.qq.com",465,2);smtp.enablessl=true;smtp.deliverymethod=smtpdeliverymethod.network;smtp.credentials=newsystem.net.networkcredential("发件箱","发件箱登录密码",2);try{smtp.send(msgmail,2);}catch(exceptionex){console.writeline("发送完毕......",2);}

这样还是不行,报操作已超时错误在国外的技术网站上看到一句话system.net.mail支持explicitssl但是不支持implicitssl,然后查了下关于这两个模式的资料,我按照我理解的说一下:

explicitssl发起于未加密的25,然后进行一个starttl握手,最终切换到加密的连接。

implicitssl直接从指定的端口发起starttl握手。

既然指定了端口,那么应该就是使用了implicitssl,不知道微软什么时候能更新下system.net.mail,system.net.mail能在邮件中嵌入图片的。问题到了这里,那是不是就没有办法利用腾讯邮箱发邮件了呢?答案肯定是否定的,foxmail不就可以配置发送邮件吗?我们可以利用cdo.message和system.web.mail发送邮件。

相关文章
{{ v.title }}
{{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
你可能感兴趣
推荐阅读 更多>
推荐商标

{{ v.name }}

{{ v.cls }}类

立即购买 联系客服