DataChomp

Chomping At The Bits

How to Test Email With Port 25 Blocked

Recently, I got rid of the business line to my house. The downside to this is losing ports 25 and 80. Port 80 isn’t a real deal breaker as when I’m coding/debugging I’m just using a local webserver. However, when I am testing email functionality in an application things get a little more interesting. The fix I found for this involves how you specify the SMTP actions in the webconfig.

In your Configuration section, you can specify either network delivery or a pickup location:

<system.net>
    <mailSettings>   <!--<smtp deliveryMethod="SpecifiedPickupDirectory"><specifiedPickupDirectory pickupDirectoryLocation="C:SubversionEmail" /></smtp>--> 
        <smtp deliveryMethod="Network"><network host="datachomp.com" port="25" defaultCredentials="true" userName="Gator@example.com" password="email" /></smtp> 
    </mailSettings>
</system.net>

At this point you just check the local directory for email when you are testing your application. If you don’t have system for production deployments, then don’t forget to change to the network delivery when you deploy.