1
Is there a free command-line-based, lightweight SMTP server for Windows?
All I'm looking for is the ability to send HTML emails from the command-line, using a standalone EXE, with the program being its own server (rather than using some other server like Gmail).
By "lightweight" I mean there should be a single executable, or -- if not possible -- it should come with at most a handful of supporting DLLs, and run standalone (i.e. without installing anything).
Specifically:
I am not looking for
hMailServer
. It may be awesome, but it's still bloated for sending a single email. I just need a command-line tool I can have handy on a flash drive or a recovery environment -- something that does not require installation.The server needs to support TLS -- i.e., it should be able to send mail to major providers like Gmail, which require encryption.
IIS fails every test: it's (1) not lightweight and (2) not standalone.
For those who claim Gmail doesn't need encryption:
$ telnet smtp.gmail.com 25
Trying 209.85.225.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP a9sm264065ibi.26
HELO
250 mx.google.com at your service
MAIL FROM: my_email@gmail.com
530 5.7.0 Must issue a STARTTLS command first. a9sm264065ibi.26
What am I doing wrong?
@Mehrdad Is it actually a server? did you check? – barlop – 2014-09-15T16:59:05.623
@RandolfRichardson You soudn familiar with Blat. The question asked for an SMTP Server. Is this actually a server? – barlop – 2014-09-15T17:00:06.667
GMail doesn't require TLS or any type of encryption for SMTP. (I just confirmed this by making a raw connection with PuTTY on TCP port 25 and manually sent a message to myself without only four commands, none of which involved any encryption.) – Randolf Richardson – 2011-08-17T04:32:17.603
@Randolf: What were the commands? Each time I tried, it told me I have to use TLS... – user541686 – 2011-08-17T04:38:58.543
Standard SMTP commands -- HELO, MAIL FROM, RCPT TO, DATA (QUIT is outside of that because a successful return code following a properly completed DATA command is all that's required to send a message; using QUIT to end the session is still important though). – Randolf Richardson – 2011-08-17T04:50:41.503
Regarding "the program being its own server," what you're looking for is what's called a "direct-to-MX mailer" that performs its own lookups for MX records (so that you don't have to specify an SMTP server). If you don't need something that will queue your message and retry later on, then a command-line tool can work quite well for that. Otherwise, I suggest David Harris' wonderful Mercury/32 mail server (doesn't use the Registry -- it's a text file configuration only) in which you can simply create a text file in the queue: http://www.pmail.com/overviews/ovw_mercury.htm
– Randolf Richardson – 2011-08-17T04:57:28.763@Randolph: How come I'm getting that error message regarding TLS? Am I issuing the wrong commands or something? And thanks for the link, I'll take a look at that! – user541686 – 2011-08-17T05:12:40.017
Try adding your hostname as a parameter to the HELO command (I believe a hostname is required, although there are many SMTP servers that don't comply with standards). – Randolf Richardson – 2011-08-17T05:21:46.913
@Randolph: I tried; it made no difference. – user541686 – 2011-08-17T06:04:02.320
You have a space after the colon for the MAIL FROM command (I didn't notice this earlier), but spaces aren't permitted in eMail addresses (unless properly quoted). You also need to enclose your eMail addresses within angle brackets. This all applies to the MAIL FROM and RCPT TO commands. See section 3.3 on page 19 of RFC 5321 (Simple Mail Transfer Protocol): http://rfc5321.openrfc.org/
– Randolf Richardson – 2011-08-17T06:08:39.583Also, you should be using the SMTP server that is defined in the MX record in the "gmail.com" DNS zone. The one with the highest priority (5) is:
gmail-smtp-in.l.google.com
– Randolf Richardson – 2011-08-17T06:14:59.3401@Randolph: :O OMG, it worked! So it was an issue with the server... interesting, thanks a lot for the info. But how do you figure out which server you need to connect to, when all you have is the email address the user gives you? Is there a way to look it up with DNS or something? Thanks! – user541686 – 2011-08-17T06:25:09.993
You have to look it up for every site. In the DNS zone there are usually MX records (if not, then just use the domain name itself, but this is always a last resort as MX records are always preferred). With each MX record will be a Priority and a Hostname (IP addresses are not allowed, and many SMTP servers will fail to deliver if an IP address is specified in an MX record); always choose the higher priorities (lower values) first. – Randolf Richardson – 2011-08-17T06:29:34.807
1@Randolph: Interesting, thanks a lot for the info; that's really helpful! (BTW, my emails went to spam, lol...) – user541686 – 2011-08-17T06:50:13.040