error when emailing from form

Discussion in 'ASP.NET / ASP.NET Core' started by DevDevil, Mar 7, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
    Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
    mailMessage.From = txtName.Text
    mailMessage.To = "[email protected]"
    mailMessage.Subject = "FROM WEBSITE"
    mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
    mailMessage.Body = txtMessage.Text
    System.Web.Mail.SmtpMail.SmtpServer = "localhost"
    System.Web.Mail.SmtpMail.Send(mailMessage)
    Me.lblMessageSent.Visible = True
    End Sub
    anybody see anything wrong here? i get this error:
    The server rejected the sender address. The server response was: 501 5.5.4 Invalid Address
    i entered a valid address.
     
  2. Is your from address a valid email address? by looking at the code you posted it looks as you might be setting the from address as the "name" and not "email address".

    some email servers will perform some validation on the email address to see if it's a valid email box also.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. That was it. Thanks. Know anything about Web.config files for directory security? I have a directory that I want to require forms authentication on but can seem to get it working.
     
  4. Try adding something like this to your web.config...



    <configuration>
    <location path="unsecure">
    <system.web>
    <authorization>
    <deny users="?"/>
    </authorization>
    </system.web>
    </location>
    </configuration>


    If you setup your forms authentication in the root web.config and want to password protect a directory, you can also slipa new web.config into the directory you want to secure...



    <configuration>
    <system.web>
    <authorization>
    <deny users="?"/>
    </authorization>
    </system.web>
    </configuration>






    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  5. Should this work? Your opinion...




    <configuration>
    <location path="myHome">
    <system.web>
    <authorization>
    <deny users="?">
    <authentication mode="Forms">
    <forms loginUrl="secure/login.aspx"/>
    </authentication>
    </deny>
    </authorization>
    </system.web>
    </location>
    </configuration>


    I put it in the myHome directory and I get this now:

    The page cannot be displayed


    You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
     
  6. I think your <authentication />node should be inside the system.web section, not inside the <deny /> node.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  7. Man I really appreciate the help wth this. I've been fighting it for a while now.
    This is what I did and I get the same error:

    <configuration>
    <system.web>
    <authorization>
    <authentication mode="Forms">
    <deny users="?">
    <forms loginUrl="secure/login.aspx"/>
    </deny>
    </authentication>
    </authorization>
    </system.web>
    </configuration>
     
  8. <forms loginUrl="secure/login.aspx"/> should also not be in the <deny /> node.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  9. I don't know. This is just giving me the same error every time. I've changed it all several times. Here's a web.config I have on another site (same host) and it works fine. The only difference is that there's no web.config file in the main web directory.

    <configuration>
    <appSettings>
    <add key="sqlCon.ConnectionString" value="Data Source=#####;Initial Catalog=#####;User Id=#####;Password=#####" />
    <!--<add key="sqlCon.ConnectionString" value="Data Source=#####;Initial Catalog=#####;User Id=#####;Password=#####" />-->
    </appSettings>
    <system.web>
    <customErrors mode="Off"/>
    <authentication mode="Forms">
    <forms loginUrl="secure/login.aspx"/>
    </authentication>
    <authorization>
    <deny users="?"/>
    </authorization>
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
    </system.web>
    </configuration>
     
  10. If it is a seperate project, go into your control panel and make that directory a "web application".


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  11. Ok, paste us your root web.config, web.config in the myHome, double check myHome is still set as a web application in the control panel, the error message you are receiving now and a url an example of the problem.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  12. You need to set your forms authentication in the root application. So if your root application is your root directory, you will have to have a web.config in there with those settings.

    I'm guessing the directory you are putting this web.config in is just a sub-directory and you have not configured it as an application. If you wish the forms auth settings to be understood you'll need to configure that directory as a "web application". Otherwise you can all of your settings out (except the <deny />) into the root application and leave the <deny /> stuff in the sub-directory.

    I hope that wasn't too confusing.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  13. It already was. This is what it said:
    Current Path:
    \htdocs\myHome
    This folder is setup as a web application. Click the button below to remove the Web Application.
    It seems like everything is set up correctly, I really don't get it now. I need to get this figured out because I have another project that I'll be starting in a few days that will have the same requirements (securing certain directories, etc...). Again, I really appreciate the time and help you've provided. Any other ideas?
     
  14. Well, I created myHome as a seperate project and then copied from visual studio.net to the directory in the root web. Never done this before. It made sense to me. Do I need to do something different?
     
  15. Just wanted to let you know I resolved the issue with the myHome directory. I removed the application on the directory and then installed it again. everything worked. Thanks for the help with this. I guess I should have tried that sooner.
     
  16. Thanks for your help with this.
    root web.config:

    <configuration>
    <appSettings>
    <add key="sqlCon.ConnectionString" value="Data Source=mssql10.discountasp.net;Initial Catalog=DB_135623_mjcoffeeco;User Id=DB_135623_mjcoffeeco_user;Password=spiritwind" />
    <!--<add key="sqlCon.ConnectionString" value="Data Source=Laptop-03;Initial Catalog=Coffee;User Id=sa;Password=872239" />-->
    <add key="SqlConnection1.ConnectionString" value=""/>
    <add key="sqlConnectionString" value=""/>
    </appSettings>
    <system.web>
    <customErrors mode="Off" />
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
    <sessionState
    mode="InProc"
    stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false"
    timeout="10080"
    />
    <!-- GLOBALIZATION
    This section sets the globalization settings of the application.
    -->
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />

    </system.web>
    I've tried it with and without this section. Currently it's there.:
    *******************************************
    <location path="myHome">
    <system.web>
    <authorization>
    <allow users="?">
    <authentication mode="Forms">
    <forms loginUrl="myHome/login.aspx"/>
    </authentication>
    </allow>
    </authorization>
    </system.web>
    </location>
    *******************************************
    </configuration>
    myHome web.config:

    <configuration>
    <appSettings>
    <add key="sqlCon.ConnectionString" value="Data Source=mssql10.discountasp.net;Initial Catalog=DB_135623_mjcoffeeco;User Id=DB_135623_mjcoffeeco_user;Password=spiritwind" />
    <!--<add key="sqlCon.ConnectionString" value="Data Source=Laptop-03;Initial Catalog=Coffee;User Id=sa;Password=872239" />-->
    <add key="SqlConnection1.ConnectionString" value=""/>
    <add key="sqlConnectionString" value=""/>
    </appSettings>
    <system.web>
    <customErrors mode="Off"/>
    <authentication mode="Forms">
    <forms loginUrl="./secure/login.aspx"/>
    </authentication>
    <authorization>
    <deny users="?"/>
    </authorization>
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="server=Master; Initial Catalog=CyFair;User id=cypress_master;Password=fairbanks_master;" cookieless="false" timeout="20"/>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
    </system.web>
    </configuration>
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page