I’m have a “Contact Us” form that I can’t get to work on the server. On localhost it works as intended but I can’t get it configured on Godaddy server. Initially, I was using a NuGet package called EASendmail which works on localhost but not the server. Then I found this in the Godaddy docs and while it’s specific to c#, I was able to get it to work on localhost… but not the server. The only thing I can think of is that I might not have this code in the correct area of web.config. Otherwise, it’s a firewall issue? If so, any ideas on how I can configure that?
<system.net>
<mailSettings>
<smtp from="your email address">
<network host="relay-hosting.secureserver.net" port="25" />
</smtp>
</mailSettings>
</system.net>
Here’s the sub:
Imports System.Net.Mail
Public Sub testMail()
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("[email protected]", "MyPassword")
Smtp_Server.Port = 25
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress("[email protected]")
e_mail.To.Add("[email protected]")
e_mail.Subject = "Test system.net.mail method"
e_mail.IsBodyHtml = False
e_mail.Body = "That worked from server!"
Smtp_Server.Send(e_mail)
'MsgBox("Mail Sent")
Catch error_t As Exception
'MsgBox(error_t.ToString)
End Try
End Sub
Here’s the web.config entry (I put it between between ‘<connectionStrings>’ and ‘<system.web>’ because I’m not sure where it’s supposed to go):
</connectionStrings>
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="relay-hosting.secureserver.net" port="25" />
</smtp>
</mailSettings>
</system.net>
<system.web>
I used port 25 because that’s what was in the Godaddy example, and also tried 587. Both work on localhost but not server. I haven’t tested with 465.
Any ideas?