cancel
Showing results for 
Search instead for 
Did you mean: 
Go to solution

Error (remote name could not be resolved) when sending email SMTP on plex hosting

I am creating an asp.net web form page using vb.net code.  I'm trying to test sending an email while running on localhost, but I keep getting an exception of "The remote name could not be resolved: 'relay-hosting.secureserver.net'"  

 

I have this in my web.config file (the email address is my address through go daddy)

<system.net>
<mailSettings>
<smtp from="me@me.com"
<network host="relay-hosting.secureserver.net" port="25"/>
</smtp>
</mailSettings>
</system.net>

 

My vb.net code:

Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click

Try
Dim SmtpClient As New SmtpClient()
Dim MailMessage As New MailMessage

MailMessage.From = New MailAddress("anotherAddress@test.com", "Test Name")
MailMessage.To.Add("me@me.com")


SmtpClient.EnableSsl = True

MailMessage.Subject = "test subject"
MailMessage.Body = "test message"

SmtpClient.Send(MailMessage)

lblMessage.Text = "Your Message has been sent."

Catch ex As Exception
lblMessage.Text = "error sending"
End Try

End Sub

 

Can someone please help me? I don't understand what I'm doing wrong.

8 REPLIES 8
Helper VI
Helper VI

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

Hello @beekeeper

 

I've never used asp, but maybe my "Google skills" will help you Smiley Happy

 

Try to see if you can apply this solution.

 

If that does not work, try this one.

 

Good luck.

Smiley Happy

***Signature: -> Do not assume anything! If you want help, explain your problem. If my post helped you, give it a Kudo. If you have the solution, mark the topic as Solved.

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

Thank you for your help.  I did try the first link and it didn't work. I don't think the second link applies to this situation, since I'm not trying to upload/download anything.  

 

I'm following GoDaddy's help page  to set up this contact form.  

 

I've used this exact asp/vb code in other applications, so I'm pretty sure there's either something wrong in the web config (which is odd since I copied from their help page) or GoDaddy is blocking it while running local host (which makes it impossible to test).  

 

I'm not sure what else to try.

Helper VI
Helper VI

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

Like you said, maybe "GoDaddy is blocking it while running local host" so why don't you upload it and test it on your "live" server?

Smiley Happy

***Signature: -> Do not assume anything! If you want help, explain your problem. If my post helped you, give it a Kudo. If you have the solution, mark the topic as Solved.

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

Unfortunately, I can't yet.  I'm still coding the rest of the site, so if I upload it it'll overwrite everything that's currently posted.  I'm the middle of swapping from straight html to asp, so uploading a new webconfig, etc will break the current site.  I just need to be able to test this particular page to make sure my emails/contact form is going to work.

Solution

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

I have contacted Go Daddy about this, and have been told that the network host will not work when running localhost, as I suspected.  They have helped to create a subdomain for me, which I can upload to for testing purposes, which will not conflict with my current site.

So, if anyone else has this issue, I recommend calling Go Daddy to help.

 

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

i am creating mvc application and i am send an email on sign up but i am getting this error. any one who told me how to solve it.

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

After trying to figure this out all day yesterday I found a post online last night, which after trying now seems to somehow work. The only difference between it and mine is that you don't set the SSL at all, and you don't set a port. And of course it only works when its uploaded to your server.
I also read that people were having to wait half an hour for an email to arrive when its "rush hour," but mine seems to be instant. 
I've never had so many issues with smtp before...

private string SendEmailFromGoDaddy(string subject, string body, string sender,  string recipient, bool isHTML, string smtpUsername, string smtpPassword)
    {
        string msg = null;

        try
        {
            MailMessage mailMsg = new MailMessage(sender, recipient);
            mailMsg.Subject = subject;
            mailMsg.Body = body;
            mailMsg.IsBodyHtml = isHTML;

            SmtpClient smtp = new SmtpClient();
            smtp.Host = relay-hosting.secureserver.net;
            smtp.Credentials = new System.Net.NetworkCredential(smtpUsername, smtpPassword);

            smtp.Send(mailMsg);
        }

        catch (Exception ex)
        {
            msg = ex.Message;
        }

        return msg;   // If msg == null then the e-mail was sent without errors
    }

Re: Error (remote name could not be resolved) when sending email SMTP on plex hosting

Yes, If you try it on your live environment it works. Localhost does not resolve this.