云服务器不能使用邮箱25端口

一、处理25端口

       ①、换用端口

1、官方建议【465端口25端口申请】。

 2、云服务器可用端口。

1、可用端口(465587)。

        ②、使用(465、587)端口问题

1、错误信息:The SMTP server requires a secure connection or the client was not authenticated.

2、错误信息: Bad sequence of commands. The server response was: Error: need EHLO and AUTH first 

       ③、完整代码(处理及解决)

1、禁用默认凭证、启用ssl。

        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <returns></returns>
        public async Task SendAsync()
        {
            MailMessage mail = new MailMessage();
            mail.To.Add(new MailAddress("apricot@qq.com"));
            mail.Body = "so far ~";
            Mail.SmtpClient smtp = new Mail.SmtpClient();
            mail.From = new MailAddress("1764564459@qq.com", "1764564459");
            smtp.UseDefaultCredentials = false;//禁用默认凭证
             smtp.EnableSsl = true;//启用ssl
             smtp.Host = "smtp.exmail.qq.com";
            smtp.Port = 587;
            smtp.Credentials = new NetworkCredential("1764564459@qq.com", "password");
            await smtp.SendMailAsync(mail);
        }

 

二、参考

        ①、常用邮箱服务器配置

 

posted @ 2023-02-15 23:12  1764564459  阅读(99)  评论(0编辑  收藏  举报