Steve Schofield's Blog

Browse by Tags

All Tags » SMTP » IIS   (RSS)

  • Getting CDONTS to work on Windows Server 2008 x64

    A few questions come up in the forums @ http://forums.iis.net about people moving Classic ASP applications that use CDONTS. CDONTS was introduced in NT4 and was widely popular. With the success of ASP applications 'back in the day', many used CDONTS to...(read more)
  • Vista and an SMTP Server on port 25 or 587

    I was answering a post in the newsgroups about a developer wanting to run IIS SMTP on Vista.  This feature is NOT included in Vista.  The person was frustrated they couldn't test their email code.  This post is meant to provide a couple examples tested on Vista Ultimate.  Here is a couple of tricks I did using FreeSMTP http://softstack.com/freesmtp.html.  The install is simple and the user interface is straight forward.   By default it has the port number and DNS server automatically configured.  Look in the picture one in the bottom of the window.

    For your purposes as a developer, you want to verify your code works when sending emails.  To show you this works on Vista, I posted 2 code samples and the email headers from an ASP and ASP.NET 2.0 webpage. Vista does not have an SMTP service like they did in 2000, XP. Vista does support the ability to have your application forward emails to a remote host.  That is the one 'feature' in the IIS manager, this is NOT an SMTP server.  The FreeSMTP one is slick because it runs interactively.  Meaning  when it's showing in the task bar, it works.

    Another thing you can do to make sure your local SMTP server is working. Change the SMTP port to 587 and send yourself a test message to your Gmail account, assuming you one.  I was able to successfully test on an alternative port, assuming your ISP is blocking port 25.  Port 587 is a well-known alternative SMTP port.  Gmail accepts email on this port.  Here is my ASP code run on my Vista box.  I couldn't figure out how to extract the email headers from my Gmail account, but the message did get there.  Hope this helps.

    Free SMTP GUI

    If your ISP blocks, you can adjust the port to 587, then test to your Gmail account.  Assuming you have one.  click File, Options close and open the program and you are good to go.

    To verify your machine has port 25 or 587 open, go to the command prompt, type netstat -an -p tcp.  You should see 0.0.0.0:25 or 0.0.0.0:587

    Test using port 587. 

    <html>
    <body>

    <%
    sch = "http://schemas.microsoft.com/cdo/configuration/"

        Set cdoConfig = CreateObject("CDO.Configuration")

        With cdoConfig.Fields
            .Item(sch & "sendusing") = 2 ' cdoSendUsingPort
            .Item(sch & "smtpserver") = "127.0.0.1"
     .Item(sch & "smtpserverport") = "587"
            .update
        End With

        Set cdoMessage = CreateObject("CDO.Message")

        With cdoMessage
            Set .Configuration = cdoConfig
            .From = "steve@example.com"
            .To = "YourAccount@gmail.com"
            .Subject = "Sample CDO Message"
            .TextBody = "This is a test for CDO.message"
            .Send
        End With

        Set cdoMessage = Nothing
        Set cdoConfig = Nothing
        response.write "Sent"
    %>


    </body>
    </html>
     

    Test using port 25

    Here is my examples.

    ------------------
    ASP.NET 2.0 page
    ------------------
    <html>
     <body>
     <%

    'create the mail message
    Dim mail As New System.Net.Mail.MailMessage()

    'set the addresses
    mail.From = New System.Net.Mail.MailAddress("steve@example.com")
    mail.To.Add("steve@example.com")

    'set the content
    mail.Subject = "This is an email"
    mail.Body = "this is the body content of the email."

    'send the message
    Dim smtp As New System.Net.Mail.SmtpClient("127.0.0.1")
    smtp.Send(mail)
     %>

     </body>
    </html>

    ------------------
    ASP.NET 2.0 page email headers.
    ------------------


    Notice the 'Received' line where it says received from pc1.aspdot.net to mail.example.com, this is my local Vista box send to an external mail server.  The only thing I changed was the 'example' word. 

    Return-Path: <steve@example.com>
    Received: from pc1.aspdot.net [192.168.0.90] by mail.example.com with SMTP;
       Fri, 7 Sep 2007 07:31:57 -0400
    mime-version: 1.0
    from: steve@example.com
    to: steve@example.com
    date: 7 Sep 2007 07:31:57 -0400
    subject: This is an email
    content-type: text/plain; charset=us-ascii
    content-transfer-encoding: quoted-printable

    this is the body content of the email.

    ------------------
    Classic ASP example
    -------------------
    <html>
    <body>

    <%
    sch = "http://schemas.microsoft.com/cdo/configuration/"

        Set cdoConfig = CreateObject("CDO.Configuration")

        With cdoConfig.Fields
            .Item(sch & "sendusing") = 2 ' cdoSendUsingPort
            .Item(sch & "smtpserver") = "127.0.0.1"
            .update
        End With

        Set cdoMessage = CreateObject("CDO.Message")

        With cdoMessage
            Set .Configuration = cdoConfig
            .From = "steve@example.com"
            .To = "steve@example.com"
            .Subject = "Sample CDO Message"
            .TextBody = "This is a test for CDO.message"
            .Send
        End With

        Set cdoMessage = Nothing
        Set cdoConfig = Nothing
        response.write "Sent"
    %>

    </body>
    </html>

    ------------------
    Classic CDOSYS email headers using cdosys
    ------------------

    Again, notice the 'Received' line where it says received from pc1.aspdot.net to mail.example.com, this is my local Vista box sending to an external mail server.

    Return-Path: <steve@example.com>
    Received: from pc1.aspdot.net [192.168.0.90] by mail.example.com with SMTP;
       Fri, 7 Sep 2007 07:26:21 -0400
    thread-index: AcfxQerDubACV5L/Q2aEgBOgiPw2rQ==
    Thread-Topic: Sample CDO Message
    From: <steve@example.com>
    To: <steve@example.com>
    Subject: Sample CDO Message
    Date: Fri, 7 Sep 2007 07:26:21 -0400
    Message-ID: <D7FBFDDB5A87496F9A7645E782A144DE@aspdot.net>
    MIME-Version: 1.0
    Content-Type: text/plain
    Content-Transfer-Encoding: 7bit
    X-Mailer: Microsoft CDO for Windows 2000
    Content-Class: urn:content-classes:message
    Importance: normal
    Priority: normal
    X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16480

    This is a test for CDO.message
     

    Thanks to www.aspfaq.com and www.systemnetmail.com for assistance on the code samples.

    Steve Schofield
    Microsoft MVP - IIS

  • Another free email / SMTP program

    I found this in the newgroups.  People are always looking for good POP3 / SMTP programs.  http://pmail.com/downloads.htm  (Mercury Mail)

  • Want to troubleshoot your email created on Windows using the SMTP Service? Turn the Service off

    I was working with a co-worker the other day trying to see what our emails looked like when they were sent from a webpage.  We had some formatting issues and wanted to see the actual message on the server right after it was generated.  The problem, we couldn't capture it fast enough on the server.

    I realized one small trick, turn just the SMTP service off that comes with IIS. Messages queue up in the local pickup folder.   After you turn the service on, the messages are delivered as normal.    This works both for troubleshooting webpages generated with classic asp, asp.net or a 3rd party script.  Here is an example of what I did.

    Stop the service.

    Generate a message

    Look in the pickup folder

    Poof! The message is still there.  Your webpage will still work.  I get a lot of questions in the newsgroups asking where are my messages or what do my messages look like.  You can review the email headers in Notepad while it remains in the pickup folder.  If you have several messages in the folder, just use the Search feature to look inside files for your message.

    Here are the headers from the sample email.


    X-Receiver: steve@example.com
    X-Sender: steve@example.com
    Thread-Topic: Sending email with CDO
    thread-index: Acd4LFre6hIxY5VuRXC44UTFQUbrpQ==
    From: <steve@example.com>
    To: <steve@example.com>
    Subject: Sending email with CDO
    Date: Fri, 6 Apr 2007 05:17:10 -0400
    Message-ID: <000001c7782c$5af81390$3e00a8c0@aspdot.net>
    MIME-Version: 1.0
    Content-Type: text/plain
    Content-Transfer-Encoding: 7bit
    X-Mailer: Microsoft CDO for Windows 2000
    Content-Class: urn:content-classes:message
    Importance: normal
    Priority: normal
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028

    This is a message.

    Here is the ASP code used to generate the message.

    <%
    Set myMail=Server.CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From=steve@example.com
    myMail.To=steve@example.com
    myMail.TextBody="This is a message."
    myMail.Send
    set myMail=nothing

    response.write "Email was sent at " & Now()
    %>

    Hope that helps in your SMTP troubleshooting.

  • Misc IIS links with great info

    I was looking for some IIS related information and ran across some 'great' links.   I wanted to post them for future reference. 

    Sample scripts for managing Web sites on Internet Information Server 6.0.
    http://www.microsoft.com/technet/scriptcenter/scripts/iis/iis6/default.mspx?mfr=true

    Sample scripts for managing the SMTP mail server included with Internet Information Server 6.0.
    http://www.microsoft.com/technet/scriptcenter/scripts/iis/iis6/default.mspx?mfr=true

    IIS7 SDK information
    http://msdn2.microsoft.com/en-us/library/aa830049.aspx

     

  • Want help with IIS SMTP Service? Please enable logging.

    When you trying to troubleshoot SMTP delivery issues and using Microsoft IIS SMTP Service.  One tip, the logging is not enabled by default.  I'm not sure why, but it can provide a ton of great information.  Pictures are worth a thousands words.  It can be done in three easy steps using IIS manager.  So the next time you have mail delivery issues, enable logging, send some test emails and see what is logged.  Notepad is a required tool for viewing them.   You can even use Logparser to query the files.  FINDSTR is my favorite quickie tool to locate information.   Impress yourself and your admin with this information the next time you have mail delivery issues.

    Note: This is not enabled by default.

    Step 1 - Enable logging

    Step 2 - this shows where the logs are located

    Step 3 - Enable all the fields so the maximum amount of information is logged

  • IIS SMTP links

    Here are some SMTP links I found that could be helpful.

    SMTP Queue Backup Occurs Due to Delivery Threads Attempting to Connect to Unavailable Hosts
    http://support.microsoft.com/kb/264891

    Great resource for mail related things
    http://www.msexchange.org

    Google is your friend
    http://www.google.com/search?hl=en&q=site%3Asupport.microsoft.com+iis+smtp

    DNSStuff.com - This is the Google of DNS troubleshooting sites.  The best hands down!
    http://dnsstuff.com

     


Powered by Community Server 2.1