Sending email C# The remote name could not be resolved

Asked

Viewed 371 times

1

I’m testing the email sending of the application for a password recovery option,I tested several ways, including email from another domain and hosting and everything works well, tested with gmail email and everything works, more with the server email does not work.

I built an example of a C# code that works perfectly with another server and works with gmail, but it doesn’t work with TOP3, I appreciate the help.

 public void EnviarEmailComSenhaAcesso()
        {
            string nome = "NOME DO CONTATO";
            string EmailContato = "[email protected]";
            string mensagem = "Mensagem";
            string login = "este e o seu login";
            string senha = "está e sua senha";

            //usando o google funciona
         //   string sUserName = "[email protected]";
          //  string sPassword = "";
            string sBobdy = "";

            //usando o servidor multiplique
            string sUserName = "[email protected]";
            string sPassword = "SENHA";


            MailMessage objEmail = new MailMessage();
            objEmail.From = new MailAddress(sUserName.Trim());
            objEmail.To.Add(new MailAddress(EmailContato, "Senha de Acesso ao site"));
            objEmail.Subject = "Recupera Senha Acesso";

            sBobdy = "Mensagem do site:\n\n" +
                                    "Nome: " + nome + "\n" +
                                    "Email: " + EmailContato + "\n" +
                                    "Login: " + login + "\n" +
                                    "Senha: " + senha + "\n" +
                                    "Mensagem: " + mensagem + "\n\n";
            objEmail.Body = sBobdy;

          //  SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587 /* TLS */);
            SmtpClient smtp = new SmtpClient("smtp.multiplick.com", 25 /* TLS */);
            smtp.EnableSsl = true;
            smtp.Credentials = new NetworkCredential(sUserName, sPassword, "");
            try
            {
                smtp.Send(objEmail);
                TempData["msg-contato"] = "A sua senha de acesso foi enviada para o seu e-mail cadastrado!";
            }
            catch (Exception ex)
            {
                // TempData["msg-contato-erro"] = "Ops..houve um problema com o envio do e - mail!Você pode tentar no telefone!";
                TempData["msg-contato-erro"] = ex.Message;
            }
        }

I have the error when using the server: inserir a descrição da imagem aqui

  • This error means that the DNS server does not contain this name, is trying from your host or the hosting server?

2 answers

1

I do not have an exact solution, but I believe it will solve the doubt. A few months ago I had the same problem you are having, I use Godaddy’s service with SMTP: relay-hosting.secureserver.net I searched in 99% of the sites and could not find a solution until I called there and they informed me basically( and in a very dirty way):

Our SMTP only works if it is on our servers. Shared hosting has limitations.

Because I believe my problem was the same as yours:

  1. I had the same Exception.
  2. The Exception happened in the localhost.
  3. When I set up a different email service (Google) it worked on localhost normally.
  4. This item probably happens(if you want test and edit the better question yet), when I raise the service in hosting(out of localhost) He wouldn’t return me to Exception.

I couldn’t find the SMTP error DIRECTLY related to the SMTP you use, but I did find that link (from Godaddy itself) where the user says:

I have contacted Go Daddy about this, and have been told that the network host will not work when running localhost, as I suspected.

I contacted Go Daddy, and they said mail server(could not understand the literal translation) will not work on Localhost as I suspected.

What I advise at this point is: Either you call on the service and the support will probably say the same as the Daddy Go support said to me, or take the test yourselfmail, if it works the problem is in what was quoted in the reply.

0

Making an appointment with the nslookup, the host smtp.multiplick.com did not appear as the MX of the domain. In a reverse query, the PTR for this host was not found. The MX of the domain I found was the mail.multiplick.com.

Switch to your code and try again:

SmtpClient smtp = new SmtpClient("mail.multiplick.com", 25);

Or

SmtpClient smtp = new SmtpClient("mail.multiplick.com", 587);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.