Thursday, January 21, 2010

Telnet commands to Send Email

I can never remember the commands to send an email via Telnet so here they are again mostly for my benefit. Examples of <smtp server> are
localhost
smtp.domain.com

C:\windows>telnet <smtp server> 25
Which should return
Connected to <smtp server>

HELO <smtp server>

MAIL FROM: admin@domain.com

RCPT TO: chuck@disney.com

DATA
Subject: Subject line of email
This text goes in the body of the email
<CR>.<CR>

Which should return
250 2.0.0 ???????? Message accepted for delivery
or
250 2.0.0 ???????? Message queued

IMPORTANT: The MAIL FROM email address should be a valid email address. Not only must the domain.com be the same domain the SMTP server is in, but don't assume that a made up email name will work. I've wasted hours trying to figure out why an email was not sent just because I didn't use a valid "mail from" address.

Should you not be able to connect to the SMTP server using the telnet command it may be because you have a firewall on the server that is blocking all outbound traffic on port 25. Or you've get the wrong SMTP server name.

Invalid handle error in Visual Source Safe

I was getting an "Invalid handle" error message the other day when trying to access Visual Source Safe and it drove me mad for a couple of days until I found a solution. So I thought I would blog it in case you run across the same problem.
I was at a customer site using my laptop which was not connected to the customer's domain. When I plug in the network cable I get issued an IP address from their DHCP server. I then fire up my Virtual Machine with my development environment on it including Visual Source Safe 2005. The virtual machine network connections are configured so that it too is issued an IP address from the customer's DHCP.
Using the logon credentials the customer has issued me, I can connect to servers and file shares on their domain.
Now the Visual Source Safe database was located on one of the customer's servers and I noticed that the network connection was unreliable. At times when I pinged the server I got "request timed out" or "host destination unreachable". The result was when I opened Visual Source Safe sometimes it would work just fine and other times it would give me the "Invalid handle" error. It got to a point where I was unable to connect to Source Safe for several days.
The solution as it turned out was quite simple. I mapped a drive letter to a network share on the VSS server. Note it's important to map a drive letter, just using "Run" to connect to the share was not enough. Now of course if you can't even ping the server then mapping the drive won't work either. But I found that once I was able to map the drive the "Invalid handle" error would go away - at least for the rest of the day. I still find that each day I need to disconnect the drive and then reconnect but it's a small price to pay to have access to VSS for the rest of the day.
So if you come across the same situation I hope this helps you to solve it.