Sendmail for Windows User Manual

Feb 26 2008

CONTENTS

System Requirements
Installation
Testing
Examples
Release History
Contacting the Author

IndigoMail (TM) is a command line program for sending E-mail messages over the Internet.

It allows sending of messages from the command line, CGI script or batch file. It is a Windows version of the popular Unix Sendmail program. It allows easy migration of perl scripts from Unix to Windows since it uses the same simple interface as the Unix Sendmail.  It provides support for sending text and binary attachments.

It can be easily integrated with your Website, or Commercial Application. IndigoMail is an ideal tool for Systems Administrators, Web Masters, Software Developers, and Integrators.

Usage:

Sendmail recipient ...

This will read a message from standard input and send it to the specified recipients. Multiple recipients are separated by spaces.  Commas and semicolons are also accepted as separators although it is not standard.

options:

-t
Scan message for recipients. SendMail will scan the message header for lines containing To:, Cc:, and Bcc: and add them to the list of recipients. Only the message header is scanned, the scan terminates when the first blank line is encountered.  Bcc: line will be deleted before transmission.

The format of a simple message with a header is given below,  the cc and bcc addresses are optional:

Subject: This is the subject
From: Some Body <somebody@example.com>
To: Some Body <somebody@example.com>
Cc: Some Body <somebody@example.com>, User Two <usertwo@example.com>
Bcc: Some Body <somebody@example.com>
<== A BLANK LINE HERE
line 1 This is the body of the message
Line 2
etc

The following forms of email address are accepted:
user.example.com
User Name <user.example.com>
"User Name" <user.example.com>
user.example.com (User Name)

Multiple addresses are separated by a comma and a space.  The space is optional.  A semicolon may also be used although it is not standard.  Addressed may be continued on a new line as long as the line starts with a one or more spaces.

-messagefile=filename
Read message from file filename. By default message is read from stdin. When reading from a file, the end of message is the end of file. When reading from the console the message can be terminated by a single period "." on a line by itself.

Specify the email address of the sender of the message. By default this value is picked up from the sendmail.ini file, or the message if the -parseheader option is used.

-subject="The subject"
Specify the subject of the message. This option is used when sending a plain text message file, which does not contain a header. The format of a simple message without a header is given below:

line 1 This is the body of the message
Line 2
etc

If this option is used SendMail will generate a message header, for the message. This option is not required if -parseheader or -t is specified and the message contains a subject line. If this option is not used, the message must contain a header (see -parseheader option).

-attach=file1,file2,...
Specify a list of files to be sent as attachments

-charset=big5
Specify charset attribute for html documents.

-debug
Capture debug information to the log file, including command line parameters.  The data passed into sendmail will be saved to file sendmail_input.txt. Debugging can also be enabled for all messages by adding this line to the sendmail.ini file:
DEBUG=1

-embed
This indicated that the message will be formatted as an html document with embedded images.  See example 9 below.

-test
Send a test message. Recipients can be specified on the command line. If no recipients are given then the message is sent to the email address configured as the default senders email address.

-logfile=filename
Specify name of log file. By default log messages are logged to file "sendmail.log" in the same directory as sendmail.exe. If Sendmail is run interactively, messages are also logged to the console.

Running SendMail without any arguments will cause it to print out a brief message including its version number.

SendMail will return a status code of 0 if successful, and non-zero if an error occurred.

-console
This will cause SendMail to print log messages to standard output.  Use this option for testing SendMail when it is invoked from a CGI script.  Make sure to print out the "Content-type: text/html\n\n" header before invoking SendMail.  Perl scripts should also have "$|=1;" line near the top of the script. -receipt This will request a read receipt from the recipient of the message. Return code The return code can be tested from batch files and perl scripts etc. Sendmail will return 0 on success and non-zero on failure. Sendmail.ini file All configuration information is kept in the file sendmail.ini . This file is a simple text file which can be edited with and text editor such as notepad. The format of the ini file is self explanatory. Most of the options in the ini file can be overridden by command line parameters. For example the mailserver specified in the ini file can be overriden with a command line parameter "-mailserver=smtp.example.com" The port parameter is not listed in the shipped ini file becasue it is rarely used, however it can be added as "PORT=xxx", where xxx is the new port to use. Adding "DEBUG=1" to the ini file is a method of capturing debug information for messages. System Requirements Requires any Windows 32 bit version, including Windows 95,98,ME, NT, 2000, XP. 2003 Installation Run the setup program. You will be prompted for an install directory. Install in the cgi-bin or scripts directory of your web server, or the windows directory or any directory in your path, or place it in the current directory To configure sendmail, edit the sendmail.ini file with notepad. To test the installation, run the following command from a dos prompt: "sendmail -test". If there are any problems, check the sendmail.log and sendmail.ini files. To install on a remote server, install SendMail for Windows on your local machine, then copy the sendmail.exe and sendmail.ini files to your server's cgi-bin directory. No special action is required if you are using a proxy mail server - specify the name of the proxy mail server when entering the mail server name. Configuring IIS 5.0 or IIS 6.0 The default installation has been found to work correctly with Sendmail. Configuring IIS 4.0 In order to use Sendmail I/O redirection must be enabled. By default you cannot use standard I/O redirection with perl and IIS 4.0. The scripting host option for IIS 4.0 is also required to be installed. This is the default. To enable standard I/O redirection run the following command, then restart the web server. %WINDIR%\system32\cscript.exe %WINDIR%\system32\inetsrv\adminsamples\adsutil.vbs set w3svc/CreateCGIWithNewConsole TRUE The above command is all on one line. Configuring IIS 3.0 By default you cannot use standard I/O redirection with perl and IIS 3.0. See the following URL on information on how configure IIS 3.0: http://support.microsoft.com/support/kb/articles/q156/7/55.asp Configuring SMTP authentication Only a few mail servers use SMTP authentication. You may be able to determine if your mail server uses it if you get an error message saying so. To enable SMTP authentication add the following lines to the sendmail.ini file. ;Authenticate to SMTP sever (yes=y) AUTHENTICATE=y ;User name for authentication USERNAME=whatever ;password for authentication PASSWORD=whatever Testing IndigoMail You can perform a basic test by running the command 'sendmail -test' from a DOS window. If you do not have DOS access to your machine you can run the smtest.pl Perl test script. The smtest.pl script will also verify your web server configuration. Contacting us for support If sendmail is not working correctly. Add the line 'DEBUG=1' to the sendmail.ini file or use the command line option -debug. Then send us the last entry from the sendmail.log file and a copy of the sendmail_input.txt file. Relay denied message If you get a message like the following: Error: Unexpected response: 550 Unable to relay for gatekeeper@example.org It may mean the sender/recipient email address combination that you have used is not acceptable to your mail server. Try using a different sender email address or only if that does not work use SMTP authentication as described above. For example if your domain name is foobar.com, then you can send email from anbody@foobar.com to anybody@anywhere.com, but you cannot send from anybody@anywhere.com to anybody@anywhere.com. Some other examples of 'Relay Denied' messages are: Error: Unexpected response: 550 <somebody@example.com>... SMTP relay denied, authenticate via POP/IMAP first Error: Unexpected response: 501 Invalid mail recipient. Relay requires SMTP AUTH. Connect Failed message If you get a connect failed message it means that the MAILSERVER entry in you sendmail.ini configuration file is incorrect, or the mail server is not responding. You need to specify the host name of an SMTP mail server. The required name should have been provided to you by your system administrator or ISP. If you are using Outlook Express you can find the by mail server host name and port by clicking on Tools, Accounts, Mail tab, a mail account, Properties, Servers tab - Outgoing Mail(SMTP) and Advanced tab - Outgoing Mail(SMTP). If you are using Netscape Mail you can find the by mail server host name by clicking on Edit, Preferences, Mail & Newsgroups, Mail Servers - Outgoing mail (SMTP) server. Once you have the host name you can verify it by using telnet to connect to it on port 25. It should print out a welcome message. If you do not see the welcome message, you do not have a valid host name. To use telnet, from a dos prompt type in the command: 'telnet hostname 25'. Try using telnet to connect to (for example) smtp.inetvs.net on port 25 (port number is important) with the command 'telnet smtp.inetvs.net 25'. You should get back a response like the following: 220 inetvs.net ESMTP Sendmail 8.8.5 ready at Wed, 13 Oct 1999 05:10:30 -0700 (PDT) Unexpected response message If you get a message like the following, try setting authentication to 'no'. Error: Unexpected response: 503 5.5.2 Send hello first. Examples 1) sendmail -messagefile=msg.txt -subject="This is the subject" name@example.com This will send a plain text file msg.txt to user name@example.com 2) sendmail <msg.txt -subject="This is the subject" name@example.com This will send a plain text file msg.txt to user name@example.com. This format can only be used when entering the command from a DOS prompt. 3) sendmail -t -messagefile=msg.txt This will send a text file msg.txt. The subject and recipient are determined from the message file. The message file must contain a header in the format given earlier. 4) Below is a perl script example: open (MAIL, "|sendmail -t"); print MAIL "To: Your Name <name\@example.com>\n"; print MAIL "From: My Name <myname\@example.com>\n"; print MAIL "Subject: This is the subject\n\n"; print MAIL "This is the body of the message\n"; print MAIL "This is line 2\n"; close (MAIL); 5) Below is a perl cgi example:$| = 1;
print "Content-type: text/html\n\n";
print "<html><body>\n";
print "Sending message<br>\n";
print "</body></html>\n";

$mailprog = 'sendmail.exe'; open (MAIL, "|$mailprog -t");
print MAIL "To: Your Name <name\@example.com>\n";
print MAIL "From: My Name <myname\@example.com>\n";
print MAIL "Subject: This is the subject\n\n";

print MAIL "This is the body of the message\n";
print MAIL "This is line 2\n";
close (MAIL);

6) Below is a perl CGI example using the CGI.pm module to email a form submission

#!perl -w
# simple CGI script email form data
use strict;
use CGI;

# path to sendmail program, if it's in the cgi-bin directory then no path is needed
# if you use a full path, then use back slashes and single quotes, e.g 'c:\path\to\sendmail'
my $mailprog = 'c:\temp\mw\cgi-bin\sendmail'; my$to_email_address = 'you@example.com';
my $from_email_address = 'you@example.com'; my$q = new CGI;

print $q->header; print$q->start_html("cgimail sample script");
print "Below is the result of the form submission<br>\n";
print $q->hr; my (@names) =$q->param;
foreach (@names) {
print "$_ = ",$q->param($_), "<br>\n"; } print$q->hr;

print "Sending mail message<br>\n";
open (MAIL, "|$mailprog -t"); print MAIL "To:$to_email_address\n";
print MAIL "From: $from_email_address\n"; print MAIL "Subject: Below is the result of the form submission 612\n\n"; foreach (@names) { print MAIL "$_ = ", $q->param($_), "\n";
}
close (MAIL);

print $q->end_html; 7) Below is a perl cgi example which does not rely on io redirection:$| = 1;
print "Content-type: text/html\n\n";
print "<html><body>\n";
print "Sending message<br>\n";
print "</body></html>\n";

$mailprog = 'sendmail.exe';$tempfile = "temp.msg";

open(MAIL,">$tempfile"); print MAIL "To: Your Name <name\@example.com>\n"; print MAIL "From: My Name <myname\@example.com>\n"; print MAIL "Subject: This is the subject\n\n"; print MAIL "This is the body of the message\n"; print MAIL "This is line 2\n"; close (MAIL); system("$mailprog -t -messagefile=$tempfile"); 8) Send a text message and word document attachments sendmail -messagefile=msg.txt -subject="This is the subject" -attach=myfile.doc name@example.com 9) Send a html message and word document attachments sendmail -messagefile=msg.html -subject="This is the subject" -attach=myfile.doc name@example.com or to specify the character set to be used in the message: sendmail -messagefile=msg.html -subject="This is the subject" -attach=myfile.doc name@example.com -charset=big5 10) Send a html message with inline images sendmail -messagefile=msg.html -subject="This is the subject" -attach=file1.gif,file2.gif.doc -embed name@example.com The html file contains text in the format below: <html><body> Here are <i>my</i> images: <img src="cid:file1.gif"> <img src="cid:file2.gif"> </body></html> 12) Below is a PHP script example: <HTML><BODY> <?php echo "Mail test program<br>\n"; ?> <?php$fp = popen ("c:\\bin\\sendmail.exe -t","w");
fwrite ($fp,"Subject: testing From: you@yourhost.com To: you@yourhost.com *insert text* "); pclose ($fp);
?>

</BODY></HTML>

13 ) PHP example using the PHP mail built-in function:

<HTML><BODY>
<?php echo "PHP Mail test program 2<br>\n"; ?>

This script sends email using the mail function<br>
The following entries in the php.ini file must be configured<br>

<pre>
[mail function]
;SMTP = localhost     <== COMMENTED OUT
sendmail_from = me@myhost.com     <== SET THIS
sendmail_path = c:\sendmail\sendmail.exe -t     <== YOU NEED THIS
</pre>

<?php

$to = "me@myhost.com";$subject = "This is the subject";
$message = "This is the message"; mail($to, $subject,$message);
?>

</BODY></HTML>

Release History

3.11 Feb 26 2008
Fixed: Multiple recipients on the command lines are incorrectly interpreted as one recipient if a semicolon is used as a separator
Fixed: Message ID is the same each time if invoked within one second with -receipt option
Debug option will save command line arguments to log file and input to sendmail_input.txt
DEBUG option can be in ini file

3.10 Feb 8 2007
Fixed: Message ID is the same each time if invoked within one second with -receipt option
DEBUG and SLOW options can be in ini file
Debug option will save input to sendmail_input.txt
Debug option will save command line arguments to log file
Added Receipt-To:" header, which will supposedly trigger a delivery status notification
Fixed: log output sometimes incorrectly displayed in web browser
Fixed: Line with single period is received as blank line
Fixed: Message corrupted if -t is not used and message is in mime format

3.01 Mar 28 2006
Fixed: Date is incorrectly formatted

3.00 Aug 22 2005
Fixed: Installer fails with 'Insufficient memory' error on Windows 2003 Server
Fixed: log output sometimes appears in browser, especially on Windows 2003
Fixed: Date is not displayed correctly on Eudora

2.05 July 5 2005
Unfold folded header lines
Fixed: The default date added to the header was wrong
Log file is written to the install directory instead of current directory
Renamed -log option to -logfile
Config file is read from install directory, does not look in current directory
Added -inifile command line option
Print a prompt when reading message from terminal window
Add date header to email, if it is not set

V2.02 Mar 16 2004
Fixed: Sending mail to some servers fails with Unexpected "250-xxx" response

V2.01 Nov 22 2003
Fixed: Message should not be made into MIME even when it is already MIME.
Added support for authentication to Microsoft Exchange server
Fixed: Regkey fails if user name contains 'none'

V2.00 Sep 6 2002
Added support for attachments with -attach and -embed options
Supports automatic recognition of html data

V1.17 June 9, 2002
Added SMTP authentication support
Updated documentation

V1.16 March 26, 2001
Will accept an IP address as well as a name for the mail server host name.
Will also accept a DNS alias for the host name of the licensed machine
Documentation includes a sample perl CGI script to email a form submission
Shortcut folder name changed to 'SendMail for Windows'

V1.15
SendMail now returns 0 on success, it was 1
Will also accept the syntax foo@bar.com (Some Name)
- provided for compatibility with formmail.pl
Added the line "#!/usr/local/bin/perl" to the smtest.pl script to make it work with Apache
Added document section on the "Connect failed" error message
Accept an IP address or a qualified or unqualified name for the licensed host name

V1.14 Mar 13, 1999
Added smtest.pl test script
Documented the -console option
IIS 4.0 configuration documentation updated
V1.13 Dec 6, 1998
Added some syntax checking of email address
Displays message if connection is terminated by mail server
Fixed: message was not sent if it was not terminated with a CRLF
Fixed: Timeout message is more descriptive

V1.12 Sep 15, 1998
-test option allows recipients on the command line
fixed: From: field in message was being ignored with the -t option

V1.11 July 14
Documentation update - expanded installation instructions
Internal code reorganization

V1.09 March 17
Default header's recipents seperator is "," was ";"

V1.08 Oct 4,97
Reply-To: Handled correctly, was treated as a recipient
Recipients on command line can be a comma seperated list
Registration key can handle domain names
Host name in registration key is case insensitive

V1.07
Full install script created
User manual is in HTML format

V1.06
Bcc: lines removed from message

V1.0
Original release

Contacting the Author

We'd like to hear your questions and comments!

Contact Information: http://www.indigostar.com/contact.htm
WWW: http://www.indigostar.com

Ordering Information

You should carefully read the following terms and conditions before using this software. Unless you have a different license agreement signed by IndigoStar Software, your use of this software indicates your acceptance of this license agreement and warranty.

Registered Version

Each registered copy of Sendmail may be used at a single workstation, subject to the following conditions:

* A separate registered copy of Sendmail must be obtained for each workstation on which Sendmail will be used even if such use is only temporary. This is not a "concurrent use" license.

All rights not expressly granted in this license agreement are reserved entirely to IndigoStar Software

Governing Law

This agreement shall be governed by the laws of the Province of Ontario, Canada.

Disclaimer of Warranty

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. Because of the various hardware and software environments into which Sendmail may be put, NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. Good data processing procedure dictates that any program be thoroughly tested with non-critical data before relying on it. The user must assume the entire risk of using the program. ANY LIABILITY OF THE SELLER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.

Shareware Version

This is not free software. You are hereby licensed to use the shareware evaluation version of Sendmail for evaluation purposes without charge for a period of 30 days. If you use this software after the 30 day evaluation period a registration fee is required. Unregistered use of Sendmail after the 30 day evaluation period is in violation of copyright laws.

Distribution of Sendmail

You are hereby licensed to make as many copies of the shareware evaluation version of this software and documentation as you wish; give exact copies of the original shareware version to anyone; and distribute the shareware version of the software and documentation in its unmodified form via electronic means. There is no charge for any of the above.

You are specifically prohibited from charging, or requesting donations, for any such copies, however made; and from distributing the software and/or documentation with other products (commercial or otherwise) without prior written permission, with one exception: Disk Vendors approved by the Association of Shareware Professionals are permitted to redistribute Sendmail subject to the conditions in this license, without specific written permission.