<network> Element (Network Settings)
Configures the network options for an external Simple Mail Transport Protocol (SMTP) server.
<network
host="host name"
port="integer"
defaultCredentials="true|false"
userName="string"
password="string"
/>
Attributes and Elements
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 |
---|---|
Configures Simple Mail Transport Protocol (SMTP) mail sending options. |
Remarks
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.
Note |
---|
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.
Example
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>