(mm) mailsend - send mail via SMTP Protocol
Search | Home | Software | Count
Software:
X/Motif
  ansi xterm
  grabc
  mdgclock
  miv
  mplaymidi
  mppp
  mxascii
  mcmap
  mxcmap
  mxconsole
  mxkill
  mxshowfont
  qtip
  xmastm
  yrolo
Web
  mhttpd
  web counter
  upload.pl
  TimeTrack.pl
  mod_auth_ldap
Games
  fltkmm
Java
   cdcl
   jdgclock
Libraries
  libcalen
  libmcfg
  libsll
  libmsock
Misc
  bangla font
  dpr
  genmake
  hod
  smtp.pl
  vhtml
  phones_ldap
  showpic_ldap
  mbasecalc
  fluid_hack
  kdialppp
MS Windows
  mwinclip.pl
  mbasecalc
  mailsend
  wiv
mailsend send mail via SMTP Protocol
(For MS Windows and Linux/Unix)
by
Muhammad A Muquit

[mailsend v1.14 (stable), v1.15b5 development]

Last Updated: Apr-27-2007

Table of Contents



Notice: Due to popular demand, STARTTLS and CRAM-MD5, PLAIN and LOGIN authentication support is added in v1.15. The code is still beta. I'm releasing it so that you can play with it. Look at ChangeLog section to see what's new in this version. -- mm, Feb-18-2007

Introduction
mailsend is a simple program to send mail via SMTP protocol (That's how all emails are sent). I needed to send a piece of alert mail from a program in a networked Windows machine, but could not find a simple program like this installed. So I wrote one. You might find it useful in some situations. The program does not use any config file and I plan to keep it that way. At this time I don't have any plan to port it to Unix. Well I had a need and I ported it to Unix (v1.05, Feb-24-2004).

Synopsis


Version: @(#) mailsend v1.14

Copyright: GNU GPL. It is illegal to use this software for Spamming

usage: mailsend [options]
Where the options are:
   -d    domain*          - domain name for SMTP Helo
   -smtp hostname/IP*    - of the SMTP server
   -p    SMTP port       - SMTP port
   -t    to,to..*        - email address/es of the reciepient/s
   -cc   cc,cc..         - Carbon copy address/es
   +cc                   - don't ask for Carbon Copy
   -bc   bcc,bcc..       - Blind carbon copy address/es
   +bc                   - don't ask for Blind carbon copy
   +D                    - don't add Date header
   -f    address*        - email address of the sender
   -sub  subject         - subject
   -l    file            - a file containing the email addresses
   -a    file,mime_type,[i/a] (i=inline,a=attachment) 
                         - attach this file as attachment or inline
   -cs   character set   - for text/plain attachments (default is us-ascii)
   -M    "one line msg"  - attach this one line text message
   -v                    - verbose mode
   -V                    - show version info
   -w                    - wait for a CR after sending the mail
   -rt  email_address    - add Reply-To header
   -rrr email_address    - request read receipts to this address
   -help                 - shows this help

The options with * must the specified
Example (Note: type without newline):

Show info amount SMTP server and exit:
 mailsend -info -smtp smtp.gmail.com

 mailsend -f muquit@example.com -d example.com -smtp 10.100.30.1
  -t muquit@muquit.com -sub test -a "file.txt,text/plain"
  -a "/usr/file.gif,image/gif" -a "file.jpeg,image/jpg"

 mailsend -f muquit@example.com -d example.com -smtp 192.168.0.2
  -t muquit@muquit.com -sub test +cc +bc
  -a "c:\file.gif,image/gif" -M "Sending a GIF file"

 mailsend -f muquit@example.com -d example.com -smtp 192.168.0.2
  -t muquit@muquit.com -sub test +cc +bc -cs "ISO-8859-1"
  -a "file2.txt,text/plain"

Change content disposition to inline:
 mailsend -f muquit@example.com -d example.com -smtp 10.100.30.1
  -t muquit@muquit.com -sub test -a "nf.jpg,image/jpeg,i"
  -M "content disposition is inline"


Note: There're no line breaks in the above commands. Also NOte:
From mailsend v1.11, filename and MIME type separator is a comma (,), the
separator used be a colon (:).
You must know the address or IP address of the SMTP server you use. The file you specify with -l contains email address one per line. For determining MIME types, please look at the file mime.types. I borrowed this file from Apache server source.

Download
You can download source if you need to look at the source for some reason or modify it. Download the compiled binary otherwise.

v1.14 Binary for MS Windows
File: mailsend.exe.zip
Size: 33609 bytes
MD5 Checksum: b9a0878bd8bdbe86ead1538f0f45d501
Last updated: Feb-10-2007

v1.14 Source for All platforms
File: mailsend1.14.tar.gz
Size: 182688 bytes
MD5 Checksum: a743ea7aa820e203abcdb602bedb6689
Last updated: Feb-10-2007

Development code with STARTTLS and Authentication support:
v1.15b5 Source for All platforms
File: mailsend1.15b5.tar.gz
Size: 189253 bytes
MD5 Checksum: 89fca6492f30e5a2b6047ce477d7221f
Last updated: Apr-27-2007

v1.15b5 Binary for MS Windows
File: mailsend1.15b5.exe.zip
Size: 236643 bytes
MD5 Checksum: deb005aee615bbcae84fd9d87b8d6e8d
Last updated: Apr-27-2007

v1.15b5 Binary for SimpleShare NAS Device
File: mailsend_ss
Size: 77000 bytes
MD5 Checksum: 27afa55a4d579cc4be53d159c08e7a1f
Last updated: Jun-10-2007

Note: about the binary for SimpleShare NAS device...
I just got a 500 GB SimpleTech SimpleShare Network Attached Storage (NAS) device. It's a sweet little device, and I needed to send some email alerts from it for certain reasons. On a side note: If you're interested in hacking SimpleShare device, look at openmss.org forum on howto enable telnet ( no need to replace firmware, just put the telnet startup script in ShareApps).

Must be compiled with latest OpenSSL if STARTTLS and CRAM-MD5 support is needed. I tested with OpenSSL 0.9.8d. Here's how to compile with openssl:

    $ sh ./configure --help
    $ sh ./configure --with-openssl=/usr/local/ssl
    $ make clean
    $ make
$ mailsend -h
Version: @(#) mailsend v1.15b5

Copyright: GNU GPL. It is illegal to use this software for Spamming

(Compiled with OpenSSL 0.9.7l 28 Sep 2006)
usage: mailsend [options]
Where the options are:
 -smtp hostname/IP*    - of the SMTP server
 -port SMTP port       - SMTP port
 -d    domain          - domain name for SMTP HELO/EHLO
 -t    to,to..*        - email address/es of the reciepient/s
 -cc   cc,cc..         - Carbon copy address/es
 +cc                   - don't ask for Carbon Copy
 -bc   bcc,bcc..       - Blind carbon copy address/es
 +bc                   - don't ask for Blind carbon copy
 +D                    - don't add Date header
 -f    address*        - email address of the sender
 -sub  subject         - subject
 -l    file            - a file containing the email addresses
 -attach file,mime_type,[i/a] (i=inline,a=attachment)
                       - attach this file as attachment or inline
 -cs   character set   - for text/plain attachments (default is us-ascii)
 -M    "one line msg"  - attach this one line text message
 -name "Full Name"     - add name in the From header
 -v                    - verbose mode
 -V                    - show version info
 -w                    - wait for a CR after sending the mail
 -rt  email_address    - add Reply-To header
 -rrr email_address    - request read receipts to this address
 -starttls             - Check for STARTTLS and if server supports, do it
 -auth                 - Try CRAM-MD5,LOGIN,PLAIN in that order
 -auth-cram-md5        - use AUTH CRAM-MD5 authentication
 -auth-plain           - use AUTH PLAIN authentication
 -auth-login           - use AUTH LOGIN authentication
 -user username        - username for ESMTP authentication
 -pass password        - password for ESMTP authentication
 -example              - show examples
 -ehlo                 - force EHLO
 -info                 - show SMTP server information
 -help                 - shows this help
 -q                    - quiet

The options with * must the specified

Example of authentication:
STARTTLS+AUTH PLAIN:
 mailsend -f muquit@example.com -d example.com -smtp smtp.gmail.com
 -sub test -from muquit@muquit.com +cc +bc -v -starttls -auth-plain
 -user you -pass 'secert'

STARTTLS+AUTH CRAM-MD5:
 mailsend -f muquit@example.com -d example.com -smtp 1.2.3.4
 -sub test -from muquit@muquit.com +cc +bc -v -starttls -auth-cram-md5
 -user you -pass 'secert'

STARTTLS+AUTH LOGIN:
 mailsend -f muquit@example.com -d example.com -smtp 1.2.3.4
 -sub test -from muquit@muquit.com +cc +bc -v -starttls -auth-login
 -user you -pass 'secert'

 mailsend -f muquit@example.com -d example.com -smtp 1.2.3.4
 -sub test -from muquit@muquit.com +cc +bc -v -starttls -auth
 -user you -pass 'secert'

Notice: CRAM-MD5 will be tried first, then Login and after that PLAIN.

(Password can be set by env var SMTP_USER_PASS instead of -pass)
Note: I suggest you always use STARTTLS if your server supports it, especially if you are using AUTH PLAIN or LOGIN.

How to Compile
In Unix:

  $ /bin/rm -f config.cache
  $ /bin/sh ./configure
  $ make clean
  $ make
The name of the binary will be mailsend

In MS Windows:
A compiled binary for MS Windows is already supplied. However, if you need to modify something or want to compile yourself, you'll need MS Visual C++ (I used MS Visual C++ 6.0). To compile, open a command shell and type:

c:\> nmake -f Makefile.win clean
c:\> nmake -f Makefile.win

It compiles cleanly with cygwin as well:

./configure
make

The name of the binary will be mailsend.exe

How to use
This is a console application, you can run it from command shell or by clicking on the app from file explorer. You can use it in many ways. I'm using 1.2.3.4 as the IP address of the SMTP server as an example, change this to your valid one. Some example are shown below:

Interactive usage

    c:>\ mailsend
    SMTP server address/IP: 1.2.3.4
    Domain: muquit.com
    From: muquit@muquit.com
    To: muquit@example.com,foo@example.com
    Carbon copy: bar@example.com
    Blind Carbon copy:
    Subject: This is a test
    =========================================================================
    Type . in a new line and press Enter to end the message, CTRL+C to abort
    =========================================================================
    this is a test
    this is a test
    .

Non-interactive usage
Everything the program needs can be fed from stdin or from a file.
Examples:

    mailsend -d muquit.com -smtp 1.2.3.4 -t muquit@muquit.com 
      -f muquit@muquit.com -sub "test" -m msg.txt
message can be passed from stdin as well:
    mailsend -d muquit.com -smtp 1.2.3.4 -t muquit@muquit.com
        -f muquit@muquit.com -sub "test" < msg.txt
If no message file is specified, it will ask to type the message:
    mailsend -d muquit.com -smtp 1.2.3.4 -t muquit@muquit.com
        -f muquit@muquit.com -sub "test"
    =========================================================================
    Type . in a new line and press Enter to end the message, CTRL+C to abort
    =========================================================================
    test. test.
    .
Also a file can be created with smtp server, from, to, cc, bcc, subject and mail body which can be used as a single input to the program. For example, if you create a file like below:
1.2.3.4
example.com
foo@example.com
bar@example.com
Mail body starts here.
This file can be used to feed to the mailsend program.

The first line is the smtp server address or IP address.
The second line is the domain used in SMTP HELO.
The third line is the From address.
The fourth line the To address/es. They can be command separated.
Right after the To the mail body starts.
Now this file can be fed as follows:
    mailsend -v < msg.txt

If it's needed to send mail to multiple people, a file can contain addresses and can be used with the flag -l. The syntax of the file is as follows:

# File can contain address to send mail to
# A line can start with To: email_address,
# Cc: email_address, BCc: email_address or
# just addresses
# Any line starts with a # or ; is considered a comment
#muquit

#muquit@muquit.com
To: blah@example.com
Cc: foo@bar.com
jdoe@gmail.com
mjane@yahoo.com

You can see the mail getting delivered if you specify the -v flag. Note: in non-interative mode, you can not specify Cc, Bcc or Subject in the file. If you need any of them specify with appropriate flags.

If you find the program useful, please let me know

Known Bugs
For text or html attachments, \r\n is not added at the ends of lines. It'll be fixed in the next release.

FAQ

  1. Q: Can this program be used as a mail sender from web browsers?

    Ans: Yes. I'll use the Firefox as an example as I use it. By default on windows Firefox will start outlook express (or nothing) to send mail when you click on a mailto: link. This behavior can be changed as follows:

    Go to Control Panel
    Click on Folder Options
    Click on File Types tab
    Click on [NONE] URL:MailTo Protocol
    Click on Advanced button
    Click on open then Click on Edit... button
    Uncheck Use DDE
    In the Application used to perform action field, add the line (without line breaks):
    
     "C:\path\of\mailsend.exe" -smtp IP_address_of_your_smtp_server
       -v -d your_domain.com
       -f you@your_domain.com +cc +bc -v -w -t "%1"
    
    Note: there's no need to clean mailto: tag from another program before calling mailsend.

    On Unix, search on the web on how to setup external mail sender for Firefox. Again there's no need to remove mailto: tag from another script.

  2. Q: Does the program support ESMTP authentication?

    Yes. From v1.15a+, STARTTLS, CRAM-MD5, LOGIN and PLAIN authentication is supported.

Copyright
GNU General Public License

ChangeLog (link)

URL of this page: http://www.muquit.com/muquit/software/mailsend/mailsend.html

back Page updated: Sun Jun 10 18:43:23 2007 GMT   Copyright © 2007 muquit@muquit.com.
Get Firefox!