Solved

web.config email settings.  Not receiving email from contact form,

Posted on 2010-08-22
6
643 Views
Last Modified: 2013-11-27
Trying to make my first contact email form.  I am using the following web.config mailsettings but am not receiving the emails.  The test/book site is live if that makes a difference. aex1.com     I used code from wrox book with a contact form and submit button. Should I be using "postmaster@discountasp.net" or my email "johndoe@aex1.com  ?  In outlook I am using smtp port 587 if that makes a difference.  Should the username and password be blank or filled in? When trying at an earlier date I did receive some delivery failure emails that said "could not deliver to johndoe@aex1.com.com  (2 .com's in email?)  Thanks

 <system.net>
    <mailSettings>
      <smtp from="postmaster@discountasp.net">
        <network host="localhost" port="25"
userName=""
password=""
defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>
0
Comment
Question by:ExpressMan1
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:GreatVargas
ID: 33497735
network host="localhost" port="25
is your email server on the same server where you have the site? because he is trying to authenticate on locahost to send mail.. he should be trying to authenticate on your email server,
0
 

Author Comment

by:ExpressMan1
ID: 33497813
Yes my email is with the same ISP.  I just tried the following mailsettings, no luck.

<system.net>
    <mailSettings>
      <smtp from="postmaster@discountasp.net">
        <network host="discountasp.net" port="25"
userName=""
password=""
defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>
0
 
LVL 14

Accepted Solution

by:
Dhanasekaran Sengodan earned 250 total points
ID: 33500398
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 15

Assisted Solution

by:GreatVargas
GreatVargas earned 250 total points
ID: 33500731
can you telnet discountasp.net on port 25 from your web server?

do from the prompt:

telnet discountasp.net 25

post the result
0
 

Author Comment

by:ExpressMan1
ID: 33501385
I tried all the variations of setting up the web.config as suggested in the links above. No luck. I am not testing locally, the site is live at aex1.com, under the about tab there is a contact form.
Here is the code from the contact form,

Imports System.Net.Mail

Partial Class Controls_ContactForm
  Inherits System.Web.UI.UserControl

  Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
    If txtPhoneHome.Text IsNot String.Empty Or txtPhoneBusiness.Text IsNot String.Empty Then
      args.IsValid = True
    Else
      args.IsValid = False
    End If
  End Sub

  Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
    If Page.IsValid Then
      Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt")
      Dim mailBody As String = System.IO.File.ReadAllText(fileName)

      mailBody = mailBody.Replace("##Name##", txtName.Text)
      mailBody = mailBody.Replace("##Email##", txtEmailAddress.Text)
      mailBody = mailBody.Replace("##HomePhone##", txtPhoneHome.Text)
      mailBody = mailBody.Replace("##BusinessPhone##", txtPhoneBusiness.Text)
      mailBody = mailBody.Replace("##Comments##", txtComments.Text)

      Dim myMessage As MailMessage = New MailMessage()
      myMessage.Subject = "Response from web site"
      myMessage.Body = mailBody

      myMessage.From = New MailAddress("you@yourprovider.com", "Sender Name Here")
      myMessage.To.Add(New MailAddress("you@yourprovider.com", "Receiver Name Here"))

      Dim mySmtpClient As SmtpClient = New SmtpClient()
      mySmtpClient.Send(myMessage)

      lblMessage.Visible = True
      FormTable.Visible = False
      System.Threading.Thread.Sleep(5000)
    End If
  End Sub
End Class

   
0
 

Author Closing Comment

by:ExpressMan1
ID: 33501516
OK, It's working.  Embarrassing, I didn't enter my email in the behind code of the contact form.!  Thanks for your help.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now