Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 <network> Element (Network Settings...
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
<network> Element (Network Settings)

Configures the network options for an external Simple Mail Transport Protocol (SMTP) server.

<configuration> Element
  <system.Net> Element (Network Settings)
    <mailSettings> Element (Network Settings)
      <smtp> Element (Network Settings)
        <network> Element (Network Settings)
<network
  host="host name" 
  port="integer" 
  defaultCredentials="true|false"
  userName="string"
  password="string"
/>

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

password

Specifies the password part of authentication to the SMTP host.

host

Specifies the host used for SMTP transactions.

port

Specifies the port number used for SMTP transactions.

defaultCredentials

Specifies whether the default network credentials on this host should be used for SMTP transactions.

userName

Specifies the user name part of authentication to the SMTP host.

Child Elements

None.

Parent Elements

Element

Description

<smtp> Element (Network Settings)

Configures Simple Mail Transport Protocol (SMTP) mail sending options.

Some SMTP servers require that you authenticate yourself to the server before use. If you want to authenticate yourself using the default network credentials on your host, set the defaultCredentials attribute to true.

You can also use basic authentication (a user name and password) to authenticate yourself to the SMTP server. To use this option, you must specify a valid user name and password for the specified SMTP server.

ms164242.alert_note(en-us,VS.90).gifNote:

Basic authentication sends the userName and password values to the server unencrypted. Anyone monitoring network traffic can view your credentials and use them to connect to the server. You should consider using a more secure authentication mechanism, such as Kerberos or NT LAN Manager (NTLM.) If defaultCredentials is true, Kerberos or NTLM will be used if the server supports these protocols.

The basic authentication and default network credentials options are mutually exclusive; if you set defaultCredentials to true and specify a user name and password, the default network credential is used, and the basic authentication data is ignored.

If you specify a userName, you should also specify a password.

The following code example specifies the appropriate SMTP parameters to send e-mail using the default network credentials.

<configuration>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="network">
        <network
          host="localhost"
          port="25"
          defaultCredentials="true"
        />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker