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


Symptom

You need to send a mail

Cause

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

Solution

You can use the mailsend free utility to do this.

mailsend -f quasimodo@lubby.org -d lubby.org -smtp 10.10.10.10 -p 26 -t quasimidi@daa-bw.de +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 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"

Spamming is wrong! Just dont do it.

Disclaimer:

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!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

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. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.