Solved

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

Posted on 2010-08-22
6
647 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

810 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