阿里云/腾讯云发送SMTP邮件失败,阿里云/腾讯云服务器不能发邮件解决方法 ,第三种方法是可以不用25端口,配置465端口阿里云/腾讯云发送邮件是成功的,现在阿里云/腾讯云25端口管理的很严要申请通过难度太大,我后面就直接用第三种方法配置465端口就可以用。
以阿里云举例:
第一种方法:解封25端口

第一步:鼠标移上右上角贵司 阿里云账号【南京XXXX】 上, 这个账号就在 【简体中文】功能左边第一个;
第二步:点击【安全管控】;
第三步:点击 【25端口解封】
第四步:点击【25端口解封申请】
第五步:填写申请的 IP和对应的邮箱域名,这里注意的是 服务器IP一定要是 阿里云账号下的服务器,域名的话,不同供应商不同的域名,客户是自己买的阿里云邮箱,邮箱域名是:mail.zhsiwei.com 配置是成功,qq邮箱可以填写 mail.qq.com就是用qq邮箱去发送邮件,qq的大家可以去试试这个域名对不,smtp.qq.com配置申请不成功,126邮箱,雅虎邮箱,这里就不一一罗列,可以去对应的邮箱里面找下就好,切记这个邮箱域名很重要配置不好审核就通不过。

第六步:填写申请表单

第七步:填写之后确定后就静静的等待阿里云客服审核一般最多7个工作日就好了
第二种方法:使用587端口
方法来源:https://blog.csdn.net/u013571196/article/details/78376343
第三种方法:使用465端口
这个方式是官方给的,主要是通过System.Web.Mail.MailMessage来实现发送,大家把这个方法放到自己的项目里面调用就好
/// <summary>/// 通过System.Web.Mail.MailMessage去发送,可以不被阿里云限制25端口的使用/// 暂时一般都用465端口/// </summary>/// <param name="smtpserver">SMTP服务,譬如:smtp.126.com</param>/// <param name="userName">发件箱</param>/// <param name="pwd">密码</param>/// <param name="nickName">昵称</param>/// <param name="strfrom">发件箱</param>/// <param name="strto">收件箱</param>/// <param name="MessageSubject">主题</param>/// <param name="MessageBody">内容</param>/// <param name="SUpFile">附件</param>/// <param name="port">端口</param>/// <param name="enablessl">SSL加密</param>/// <returns></returns>public static bool SendWebEmail(string smtpserver, string userName, string pwd, string nickName, string strfrom, string strto, string MessageSubject, string MessageBody, string SUpFile, int port, int enablessl = 0){ System.Web.Mail.MailMessage mmsg = new System.Web.Mail.MailMessage(); //邮件主题 mmsg.Subject = MessageSubject; mmsg.BodyFormat = System.Web.Mail.MailFormat.Html; //邮件正文 mmsg.Body = MessageBody; //正文编码 mmsg.BodyEncoding = Encoding.UTF8; //优先级 mmsg.Priority = System.Web.Mail.MailPriority.High; System.Web.Mail.MailAttachment data = null; if (SUpFile != "") { SUpFile = HttpContext.Current.Server.MapPath(SUpFile);//获得附件在本地地址 System.Web.Mail.MailAttachment attachment = new System.Web.Mail.MailAttachment(SUpFile); //create the attachment mmsg.Attachments.Add(attachment); //add the attachment } //发件者邮箱地址 mmsg.From = string.Format("\"{0}\"<{1}>",nickName, strfrom); //收件人收箱地址 mmsg.To = strto; mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //用户名 mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName); //密码 不是邮箱登陆密码 而是邮箱设置POP3/SMTP 时生成的第三方客户端授权码 mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd); //端口 mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", port); //使用SSL mmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", (enablessl == 1 ? "true" : "false")); //Smtp服务器 System.Web.Mail.SmtpMail.SmtpServer = smtpserver; try { System.Web.Mail.SmtpMail.Send(mmsg); } catch (Exception ex) { LogHelper.Error(ex.ToString()); return false; } return true;}
阿里云发送SMTP邮件失败,阿里云服务器不能发送邮件,其中注意的是填写的密码不是邮箱登陆密码 而是邮箱设置POP3/SMTP 时生成的第三方客户端授权码,
自己亲测试过可以用希望对大家有帮助
官网案例:https://help.aliyun.com/knowledge_detail/60692.html
转载地址:https://www.cnblogs.com/axinno1/p/8303130.html