简体   繁体   中英

smtpclient windows server 2008, This mail server requires authentication (1) when attempting to send via this SMTP (submission) port

When I want to send e-mail with c #, smtpclient: "This mail server requires authentication (1) when attempting to send via this SMTP (submission) port " receive error on windows server 2008 r2 server. But I don't have any problems when I tried it on my own computer (Windows 10). I tried closing the firewall, but there was no solution. There are no errors in the windows log. This server also installed sharepoint 2010. To send mail via Share point, the smtp server service is running. Could these two overlap? Where can I check?

public bool SendMail() {

        MailAddress SenderMailAddress = new MailAddress(GonderenEPosta, GonderenAdi == "" ? "" : GonderenAdi);
        MailAddressCollection RecipientMailAdresses = ParseRecipients(Alicilar);
        if (RecipientMailAdresses.Count==0)
        {
            Sonuc = "Mail Adresi Geçersiz";
            hataKod = 1;

            return false;
        }
        SmtpClient MailClient = new SmtpClient();
        MailClient.Host = Server;
        MailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
        MailClient.EnableSsl = SSL;
        if (Port==0)
        {
            Port = 587;
        }
        MailClient.Port = Port;           


        NetworkCredential auth = new NetworkCredential();
        if (Parola != "")
        {                                
            //auth = new NetworkCredential(GonderenEPosta, Parola);               
            MailClient.Credentials = new NetworkCredential(GonderenEPosta, Parola);               
            MailClient.UseDefaultCredentials = false;                
        }
        else
        {
            MailClient.UseDefaultCredentials = true;
        }
        MailMessage Email = new MailMessage();
        Email.IsBodyHtml = HTML;
        Email.Subject = Konu;
        Email.From = SenderMailAddress;
        Email.Body = EPosta;
        if (TeslimIste)
        {
            Email.DeliveryNotificationOptions = 
                DeliveryNotificationOptions.OnSuccess| DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay;
            Email.Headers.Add("Disposition-Notification-To", GonderenEPosta);    
        }
        if (OkunduIste)
        {                
            Email.Headers.Add("Return-Receipt-To", GonderenEPosta);
            Email.Headers.Add("Read-Receipt-To", GonderenEPosta);
        }

        if (!String.IsNullOrEmpty(UniqueID))
        {
            Email.Headers.Add("X-Yeniyol-ID", UniqueID);
        }

        foreach (MailAddress r in RecipientMailAdresses)
        {
            if (Gizli==true)
            {
                Email.Bcc.Add(r);
            }
            else
            {
                Email.To.Add(r);
            }

        }

        for (int i = 0; i < EkDosyalar.Count; i++)
        {
            Email.Attachments.Add(new Attachment(EkDosyalar[i]));
        }

        bool resp = false;
        try
        {

            ServicePointManager.ServerCertificateValidationCallback =
            delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            {
                return true;
            };

            MailClient.Send(Email);
            Sonuc = "Gönderildi";
            resp = true;
        }
        catch (Exception ex)
        {
            string msj = ex.Message;
            if (ex.InnerException != null)
            {
                msj += ", İç hata:" + ex.InnerException.Message;
            }
            Sonuc = "Gönderilemedi : \n" + msj;
            hataKod = 2;
        }
        MailClient = null;
        return resp;
    }

OK, I found the problem. We renewed our mail server 3 days ago. mail.XXXXX.com address has not changed but the ip address has changed. Therefore, the DNS address exchange was supposed to be done on the mail sending server. I've fixed the IP address that appears on mail.XXXX.com from the DNS services menu, and the problem is resolved.

:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM