LKBEN10680: Howto send a mail from a command line or cmd under windows

This article has not been checked!

LKB | Created: 02/04/2020 | Version: 0 | Language: EN | Rating: 0 | Outdated: False | Marked for deletion: False

Author: Wim Peeters - Keskon GmbH & Co. KG


You need to send a mail


This is a usefull feature and can be used in lots of situations


You can use the mailsend free utility to do this.

mailsend -f -d -smtp -p 26 -t +cc +bc -sub %computername% -M "content of the mail"

For more information you can use the help:

E:\>mailsend /h

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  - attach this file
   -cs   character set   - for text/plain attachments (default is us-ascii)
   -m    file,mime_type,[i/a] (i=inline,a=attachment)
                         - attach the file (text,html etc) as body (inline)
   -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):

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

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

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

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

Spamming is wrong! Just dont do it.

About the Author

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.


The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!