Email Service works just fine locally but it doesn't work when the site is deployed to godaddy host

143 views Asked by At

I have a function that sends email in my website. My website is written in Visual Basic and my email sender function is below:

Dim mail As New MailMessage()
mail.Subject = Trim(TextBox1.Text())
mail.Body = Trim(TextBox2.Text())
Try
        Dim SmtpServer As New SmtpClient()
        SmtpServer.Host = "smtpout.secureserver.net"
        SmtpServer.Port = 80
        SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "password")
        mail.From = New MailAddress("[email protected]")
        mail.To.Add("[email protected]")
        mail.CC.Add(Trim(HiddenField1.Value()))
        mail.Subject = Trim(TextBox1.Text())
        mail.Body = Trim(TextBox2.Text())
        mail.IsBodyHtml = True
        SmtpServer.Send(mail)
        Response.Redirect("Welcome.aspx", False)
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try

The email function and everything worked just fine on my local dev machine. But they never worked when I deployed to the windows hosting in GoDaddy. Here is what I get as an exception:

enter image description here

I know that GoDaddy has some strict rules for sending emails. But to avoid this, I couldn't find good documentation. What am I missing?

1

There are 1 answers

2
Rahul On BEST ANSWER

The host name is probably not the right one.

SmtpServer.Host = "smtpout.secureserver.net"

Godaddy mentions this as a blanket host for most of the SMTP related requests. But, they have actually implemented a system where each user is given a sandboxed access to its SMTP service. The combination of hostname and port is used to uniquely identify the user.

You could find this in your settings, their terminology is email relay server.

Reference: Godaddy