Solved

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

Posted on 2010-08-22
6
650 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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