I have a contact form on my website, that when filled out the information is suppose to be sent to my email. It works fine on the localhost, but when on the server I get this error.
An attempt was made to access a socket in a way forbidden by its access permissions 64.233.180.109:587
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 64.233.180.109:587
Source Error:
Line 42:
Line 43: SmtpClient mySmtpClient = new SmtpClient();
Line 44: mySmtpClient.Send(myMessage);
Line 45:
I have tried disabling my firewall, and my antivirus software. I am trying to get it to go to my gmail account using port 587. I also went into my firewall and enabled that port number with my domain address, which is
www.portfoliobrown.com.
Here is a copy of my back end coding in C#
protected void SendButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
string mailBody = File.ReadAllText(fileName);
mailBody = mailBody.Replace("##Name##", Name.Text);
mailBody = mailBody.Replace("##Email##", EmailAddress.Text);
mailBody = mailBody.Replace("##HomePhone##", PhoneHome.Text);
mailBody = mailBody.Replace("##BusinessPhone##", PhoneBusiness.Text);
mailBody = mailBody.Replace("##Comments##", Comments.Text);
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Response from web site";
myMessage.Body = mailBody;
myMessage.From = new MailAddress("
[email protected]", "Stephen Brown");
myMessage.To.Add(new MailAddress("
[email protected]", "Stephen Brown"));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);
Message.Visible = true;
System.Threading.Thread.Sleep(10000);
}
So I am not sure where else to go I tried to google some answers, but couldn't fine what I was really looking for. Found some people with the same error, but not exactly the same situation as I have.
Thanks a lot for any help
Stephen