Steve Schofield's Blog

Browse by Tags

All Tags » SMTP   (RSS)

  • CDOSYS and Windows Server 2008, 80070005 Description Access is denied

    I got a question from Bradley J. Dinerman about getting Aspmail working on Windows Server 2008. I've yet to figure out how to get AspEmail working on Windows Server 2008, I tried x64 and x86 of Windows Server 2008. I got the following error. Process monitor...(read more)
  • Send email with powershell cmd-let

    I've been reading the Powershell newsgroup, which is pretty much the authoritative source for community help. http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.windows.powershell For those who want to send email...(read more)
  • 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)
  • SMTP links for IIS

    I was answering a question @ http://forums.iis.net on SMTP scripting. I ran across a couple links I wanted to share. Programatically configure SMTP service on IIS to route mails to a domain http://blogs.msdn.com/mahjayar/archive/2004/11/08/254202.aspx...(read more)
  • Windows Server 2008 SMTP Service logging tip

    I was working on deploying a Windows Server 2008 x64 edition and discovered the SMTP Service wasn't logging. SMTP was working and emails were going out. My install is 'custom' and installs just the modules we needed. Turns out, there is a small dependency...(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

  • Send email from your local machine

    A common question that comes up in the newsgroups is how to setup your local machine to relay email.  Windows 2000 / XP comes with the built-in SMTP service, Vista does not provide this optioni.  You can configure this by simply installing and configuring the relay option.  After you have installed the SMTP service option, open IIS Manager >> Right click properties on Default SMTP Virtual Server >> Select Access Tab >> Relay option and put 127.0.0.1.  Secondly, I recommend you enable logging so when you are trying to verify things are working, you can review the logs.  Here is my blog on enable logging.  http://weblogs.asp.net/steveschofield/archive/2007/03/25/want-help-with-iis-smtp-service-please-enable-logging.aspx  Note the logs are located by default in c:\windows\system32\logfiles\smtpsvc\smtpsvc1

    The biggest hangup most people have their ISP only allows them to route certain emails or blocks port 25 all together.  You'll want to check with your ISP or test sending emails to an external address from the machine running the SMTP service.  You can use a simple telnet test locally.  http://support.microsoft.com/kb/153119 to an an email address such as yahoo.com, MSN, Gmail or another free provider.  If you receive the telnet test, you know your local SMTP server is working.  If it's stuck in the Queue or Pickup directory, there is a problem, either your local ISP doesn't allow relaying or something else.  This is where the logs come in handy.  Another tool for verifying your config is SMTPDiag. 

    Bottom line, this is not an exact science.   A lot of people think it is really hard to configure the mail server, it isn't the too bad.  It is understanding there are external factors like the ISP not allowing the operation in the first place or DNS not configured properly.  The DNS is another common mis-configuration, but if your machine is connected to the internet through a router or other machines, most likely the telnet test or simple email test will resolve the MX (mail exchanger) records.  This posting is not intended to teach how email works, but hopefully you get the idea. 

    So the final question, how do I verify my port 25 is open.  You can either send a telnet test or find an external port scanner that will scan your IP address.  If your machine is listening on port 25, you'll see the port open in the results.  Most people are running a local firewall that will block the scan or a router such as linksys.  You can temporarily unblock port 25 on both your router and your local firewall so the scan will determine if port 25 is open.  If your ISP is blocking it, port 25 will not show up in the results.  At least by you unblocking the two common points you control, this can help isolate the ISP issue. 

    If you have other thoughts or experiences, please share them.  I hope this post helps you in your quest to get the mail server working, so you can send email from a 3rd party program, your ASP / ASP.NET application or some other program.

  • 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)

  • Outlook 2007 performance tips

    Are you experiencing POP3 issues with Outlook 2007?  Here is a couple articles you should check out.

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;935400

    An Outlook update was released that provided significant performance benefits, especially for users with large stores (the download can be found at http://www.microsoft.com/downloads/details.aspx?FamilyID=c262bcfd-1e09-49b6-9003-c4c47539df66&DisplayLang=en).

  • 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