发送SMTP邮件客户端和服务器无法通信,因为它们不具有通用算法SMTP

发布于 2025-01-18 03:51:45 字数 1184 浏览 2 评论 0原文

我正在尝试使用SMTP生成电子邮件,但我不想添加Creadentials我的代码。在我本地的PC上工作正常,但是在服务器上,

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(SmtpServer_con);
mail.From = new MailAddress(MailFrom);
mail.To.Add(emailToID);
htmlString = @"<html><body>";
htmlString = htmlString + EmailBody;
htmlString = htmlString + "</body></html>";
mail.Subject = EmailSubject;
mail.Body = htmlString;
mail.IsBodyHtml = true;
if (SenderEmailID.ToString() != "")
{
    SmtpServer.Credentials = new System.Net.NetworkCredential(SenderEmailID, SenderEmailPassword);
    SmtpServer.Port = int.Parse(Port);
    if (SSL == "1")
    {
        SmtpServer.UseDefaultCredentials = true;
    }
    else
    {
        SmtpServer.UseDefaultCredentials = false;
    }
}

else
{
    SmtpServer.UseDefaultCredentials = true;
}
try
{
    SmtpServer.Send(mail);
    CtlCommon.CreateErrorLog("GenerateEmail ", "Sent Succesfully");
}

如果我将SSL设置为TURE,

则会给我错误

失败发送电子邮件客户端和服务器无法通信,因为它们不具有通用算法

,如果我将SSL用作false并尝试使用我的凭据,我会遇到以下的错误

SMTP服务器需要安全连接或未对客户端进行身份验证5.7.57

客户希望在没有凭据的情况下发送电子邮件

I am trying generate email using SMTP but i dont want to add creadentials my code. At my local PC is working fine but on server it is giving me error

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(SmtpServer_con);
mail.From = new MailAddress(MailFrom);
mail.To.Add(emailToID);
htmlString = @"<html><body>";
htmlString = htmlString + EmailBody;
htmlString = htmlString + "</body></html>";
mail.Subject = EmailSubject;
mail.Body = htmlString;
mail.IsBodyHtml = true;
if (SenderEmailID.ToString() != "")
{
    SmtpServer.Credentials = new System.Net.NetworkCredential(SenderEmailID, SenderEmailPassword);
    SmtpServer.Port = int.Parse(Port);
    if (SSL == "1")
    {
        SmtpServer.UseDefaultCredentials = true;
    }
    else
    {
        SmtpServer.UseDefaultCredentials = false;
    }
}

else
{
    SmtpServer.UseDefaultCredentials = true;
}
try
{
    SmtpServer.Send(mail);
    CtlCommon.CreateErrorLog("GenerateEmail ", "Sent Succesfully");
}

if i set ssl as true i am getting below errors

failure Sending Email the client and server cannot communicate because they do not possess a common algorithm

and if i use ssl as false and try to use my credentials i am getting below errors

the smtp server requires a secure connection or the client was not authenticated 5.7.57

Client wants to send email without credentials

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文