3

Ever since a windows update that took down my IIS6 mail server a few weeks back, I've been really paranoid about my mail server working.

So every time I run a windows update I fire up command prompt and send myself a quick test mail.

Like so:

> telnet localhost 25
> helo domain.com
> mail from: [email protected]
> rcpt to: [email protected]
> data
some random body to mail myself
.

This is a realy great way to test my mail server, but it's a pain in the neck to do quickly. Is there anyway i can run this in a batch script or something as a quick test?

I've tried a bat file but this just waits after i call telnet I've also explored if telnet accepts any input files and it does not seem to.

What's the best way to do this?

0

4 Answers 4

3

There's a command line utility called blat that can be used to send e-Mail in Windows.

In UNIX, you could use the userland tool to interact with the queue. Most MTAs have /usr/sbin/sendmail equivalents symlinked from the same location. The mail utility is available on most systems as well.

I'm entirely on board with Chris' monitoring recommendation, if you don't already have monitoring. Otherwise, verification of functionality after a change makes plenty of sense.

2
  • I use blat on a regular basis (auto-emails everyday) on a WinServer 2003 and it works well. All commands can be run from batch file. May 26, 2010 at 18:54
  • perfect, exactly what I was looking for!
    – WebDude
    Jun 3, 2010 at 19:29
3

PowerShell is your friend. Check out the Send-MailMessage cmdlet.

$date = Get-Date
Send-MailMessage -From "User <[email protected]>" -To "Recipient <[email protected]>" -Subject "Test message $date" -SmtpServer mailserver.domain.com

Save that into a notepad file named send-testsmtpmessage.ps1 and run it from PowerShell. You can even setup a bat file that invokes PowerShell and the script just by clicking on the file. Done.

The email will read with the subject line of something like this:

Test message 05/27/2010 23:02:04

2
  • That syntax looks like a direct copy of what Blat uses. :) May 28, 2010 at 5:05
  • the looked like an ideal solution. unfortunately I only have Powershell 1.0 and this required Powershell 2.0 Getting blat to work was easier than figuring out how to install powershell 2 on Windows Server 2008 R1. I Will try this when i move over to R2
    – WebDude
    Jun 3, 2010 at 19:30
0

You could have Servers Alive sat running to test the server and any services that you want to monitor - this a couple of add-ons that do mail flow checking which may work for you.

0

I addition to Blat, which Warner mentioned, there are a number of other command line mailers for Windows. You can also do the same through a variety of programming and scripting languages. Perl makes things especially easy. I've even seen Powershell examples in answers to other questions on this site, although that is the most cryptic scripting language I've seen for many years.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .