Unable to send e-mail from "Contact Us" form via DASP SMTP

Discussion in 'ASP.NET 2.0' started by rearndt, Jan 12, 2009.

  1. I have a "Contact Me" page on my DASP-hosted website to receive comments from viewers. However, the maildoes not get relayedthrough the DASP SMTP server to the destination address. I have it configured per instructions in the KB articles.

    My web.config settings are :

    <system.net>
    <mailSettings>
    <smtp from="">
    <networkhost="smtp.mydomain.net"userName="username" password="password"port="25" />
    </smtp>
    </mailSettings>
    </system.net>

    The C#code in my submit button click event handler is :

    MailMessage mailMessage = new MailMessage();
    mailMessage.From = new MailAddress(email.Text.Trim());
    mailMessage.To.Add(new MailAddress("[email protected]"));
    mailMessage.Subject = subject.Text.Trim();
    mailMessage.Body = message.Text.Trim();
    mailMessage.IsBodyHtml = false;
    SmtpClient smtpClient = new SmtpClient("localhost");
    smtpClient.Send(mailMessage);

    Can anyone spot what I am doing wrong?

    Thank you very much!
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Change the smtp host

    Change this line <network host='smtp.mydomain.net' userName='username' password='password' port='25' />

    to

    <network host='localhost' port='25' />

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Bruce,

    Thanks for your reply. However, I tried this and it doesn't work either. You saw my code in both the web.config and my code-behind aspx page.

    Any other thoughts? There must be something wrong since I'm sureothers are able to have visitors submit e-mail via a "Contact Us" page like mine.

    I appreciate your help.

    Bob Arndt
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    what do you mean it doesn't work? do you get error?

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Bruce,

    I mean that the mail never reaches the destination address. I've checked and rechecked the e-mail address I've used in my MailMessage object (mailMessage.To.Add(new MailAddress("[email protected]"));) and it is correct (although the address in this message is not the real one). The destination e-mail address is active and I received other mail there.

    I do not receive an error when the message is sent via my "Contact Us" page.

    Thanks.

    Bob

    P.S. You can try it yourself. My site is www.robertarndt.net.
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    you should open a support ticket w/ the from / to address. we should be able to trace the message for you.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. Bruce,


    I have submitted a ticket as you suggested. Thanks again.


    Bob Arndt
     

Share This Page