fake sendmail for windows

fake sendmail for windows

about

sendmail.exe is a simple windows console application that emulates sendmail’s "-t" option to deliver emails piped via stdin.

it is intended to ease running unix code that has /usr/lib/sendmail hardcoded as an email delivery means.

it doesn’t support deferred delivery, and requires an smtp server to perform the actual delivery of the messages.

i’ve had reports that TLS/SSL is not working on windows 8. unfortunately i don’t have access to a windows 8 system to diagnose the issue just yet.

install
  • download sendmail.zip and unzip its contents
  • copy sendmail.exe and sendmail.ini to \usr\lib on the drive where the unix application is installed
    eg. if your application is installed in c:\bugzilla, sendmail.exe and sendmail.ini need to be copied to c:\usr\lib\sendmail.exe and c:\usr\lib\sendmail.ini.
  • configure smtp server and default domain in sendmail.ini
using fake sendmail

generally all you need to do is install sendmail.exe in \usr\lib, and existing code that calls /usr/lib/sendmail will work.

if you’re coding new applications, all you need to do is construct your email message with complete headers, then pipe it to /usr/lib/sendmail -t

for example, to use fake sendmail from the command line:

@ECHO OFF
REM send email from command line via SMTP with sendmail

ECHO From: byron@example.com > %TEMP%\temp.mail
ECHO To: someone-else@example.com >> %TEMP%\temp.mail
ECHO Subject: this is a test >> %TEMP%\temp.mail
ECHO.>> %TEMP%\temp.mail
ECHO testing. >> %TEMP%\temp.mail
ECHO blah blah.. >> %TEMP%\temp.mail
ECHO. >> %TEMP%\temp.mail
ECHO blah. >> %TEMP%\temp.mail

sendmail -t < %TEMP%\temp.mail

DEL %TEMP%\temp.mail

note ECHO. puts a blank line in the file, not a line with a single period on it.

note: if you have IIS installed, you can send emails without any third party programs (you do NOT need my sendmail wrapper).

@ECHO OFF
REM send email from command line via IIS

REM change this path to point to IIS's pickup directory
SET root=c:\InetPub\MailRoot\Pickup

REM set up temp and eml filenames
IF NOT EXIST %root%\temp MKDIR %root%\temp
:setTempFileName
SET tmp=%RANDOM%
IF EXIST %root%\temp\%tmp%.tmp GOTO setTempFileName
SET eml=%root%\%tmp%.eml
SET tmp=%root%\temp\%tmp%.tmp

REM build the email.  ^ is the escape character
ECHO From: bob.smith@example.com> %tmp%
ECHO To: sally.jones@example.com>> %tmp%
ECHO Subject: Example>> %tmp%
ECHO Content-Type: text/html>> %tmp%
ECHO.>> %tmp%
ECHO ^<b^>This is a test^</b^>>> %tmp%

REM move the temp file into the pickup directory for delivery
RENAME %tmp% %eml%
alternatives

msmtp is an excellent open-source sendmail replacement.

 

http://glob.com.au/sendmail/

Leave a comment