How to specify a nonstandard SMTP port using System.Web.Mail?

We usually set the IIS SMTP services' incoming SMTP port to 8025 when we release a server. This prevents conflicts with other mail servers such as SmarterMail and still allows the IIS SMTP server to run for outgoing mail delivery.

When using System.Web.Mail in ASP.NET it then becomes necessary to change the port which it connects to the server.

The trick is to add a Field to the MailMessage object to set the port number (which makes no sense, but it works):

objMailMessage.Fields("http://schemas.microsoft.com/cdo/configuration/smtpse
rverport") = "8025"

You will also need to add 127.0.0.1 and the IP's of the server to the IIS SMTP relay list.

Article ID: 6, Created On: 3/6/2006, Modified: 10/20/2011

Feedback (0)