SMTP Configuration

Discussion in 'Email' started by azizafifi, Dec 14, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. 1-how to configure the web.config file
    2-how to configure the register.aspx file "to send the email"
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

  3. This code is 100% works with me
    Dim client As New SmtpClient
    client.Host = ("smtp.gmail.com")
    client.Port = ("587")
    client.EnableSsl = True
    client.Credentials = New System.Net.NetworkCredential("[email protected]", "MyPassword*****")
    client.EnableSsl = True
    client.Send(message)
    //////This is not working /////
    Now What should I put
    client.Host = ("smtp.mydomain.com") ???
    client.Port = ("25") ???
    client.EnableSsl = False ???
    client.Credentials = New System.Net.NetworkCredential("[email protected]", "MyPassword*****") ??? Do I really need it or not ???

    Thanks ;
     
  4. -Use 'localhost' as your smtp server.

    -Do not enable SSL as this is not supported.

    -Use port 25

    -No need to authenticate if you are sending via our web server so you don't have to use System.Net.NetworkCredential.
     
  5. Sending email via Silverlight for a web service hosted by DiscountASP.net

    I am trying to do the same thing in Silverlight following this simple example: http://www.silverlightnext.com/2010/06/send-email-from-silverlight-application.html

    See also here: http://tinyurl.com/7hfph65

    See the relevant code below. It is not working because I think perhaps I should in the <mailSettings> be using host="localhost"??? YES. That was the key, thanks to the hint by user keikoraca.
    I am trying to send from a web service hosted by DiscountASP.net in my account, and I do have an email account named “test” (i.e. test@ MYDASPSITE.com).

    So for future reference note the changes made to the Web.config file of your web service. Change to “localhost” even though it is being handled by DiscountASP.net.

    THIS Web.config file WORKS:

    <?xml version="1.0"?>
    <configuration>
    <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <system.net>
    <mailSettings>
    <smtp>
    <network host="localhost" port="25" userName="test" password="MYPASSWORD"/>
    </smtp>
    </mailSettings>
    </system.net>
    <system.serviceModel>
    <behaviors>
    <serviceBehaviors>
    <behavior>
    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
    <serviceMetadata httpGetEnabled="true"/>
    <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
    <add prefix="http://MYDASPSITE.com"/>
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    </system.serviceModel>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
    <!--for SMTP see this URL on how to configure web.config http colon backslash blackslah /tinyurl.com/7hfph65 -->
    </configuration>



    THIS Web.config file DOES not WORK (note the one line difference, no localhost):


    <?xml version="1.0"?>
    <configuration>
    <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <system.net>
    <mailSettings>
    <smtp>
    <network host="smtp.MYDASPSITE.com" port="25" userName="test" password="MYPASSWORD"/>
    </smtp>
    </mailSettings>
    </system.net>
    <system.serviceModel>
    <behaviors>
    <serviceBehaviors>
    <behavior>
    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
    <serviceMetadata httpGetEnabled="true"/>
    <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
    <add prefix="http://MYDASPSITE.com"/>
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    </system.serviceModel>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
    <!--for SMTP see this URL on how to configure web.config http colon backslash blackslah /tinyurl.com/7hfph65 -->
    </configuration>

    //END
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    When you use SMTP authentication, the username needs to be [email protected] (rather than just the username)
     
  7. Similar issues

    I've just discovered that my website has not been sending emails for 6 months now without me changing any settings. Not best pleased!

    My old settings:
    Code:
    <smtp from="[email protected]">
        <network enableSsl="true" 
                      host="localhost" port="25"
                      userName="[email protected]"
                      password="My_PASSWORD" />
    </smtp>
    
    My new settings based on the content above:

    Code:
    <smtp from="[email protected]">
        <network host="localhost" 
                     port="25" 
                     userName="postmaster" 
                     password="My_PASSWORD" />
    </smtp>
    

    These are still not working. Can anyone please explain why?
     
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