mailsend - Send mail via SMTP protocol from command line

时间:2022-08-12 18:14:56

Introduction

mailsend is a simple command line program to send mail via SMTP protocol. I used to send a piece of alert mail from a program in a networked Windows machine. You might find it useful in some situations.

 

Latest Development version is 1.17b14

mailsend - Send mail via SMTP protocol from command line  mailsend1.17b14.exe   959 KB

 

Synopsis

 

Version: @(#) mailsend v1.17b14

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

 (Compiled with OpenSSL version: OpenSSL 1.0.0g 18 Jan 2012)
 usage: mailsend [options]
 Where the options are:
  -copyright            - show copyright information
  -smtp hostname/IP*    - Hostname/IP address 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 recipient/s
  -cc   cc,cc..         - Carbon copy address/es
  +cc                   - do not ask for Carbon Copy
  -ct   seconds         - Connect timeout. Default is 5 seconds
  -bc   bcc,bcc..       - Blind carbon copy address/es
  +bc                   - do not ask for Blind carbon copy
  +D                    - don not add Date header
  -f    address*        - email address of the sender
  -sub  subject         - subject
  -lilst file           - a file containing a list of email addresses
  -log file             - write log messages to this file
  -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)
  -enc  type            - Encoding Type. Only valid type: base64
  -H    "header"        - Add custom Header
  -M    "one line msg"  - attach this one line text message
  -name "Full Name"     - add name in the From header
  -v                    - verbose mode
  -show_attach          - show attachment in verbose mode, default is no
  -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
  -ssl                  - SMTP over SSL
  -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 be specified. Environment variables: SMTP_USER_PASS for plain text password (-pass).
  For determining MIME types, please look at MIME Types.

 

Examples

 

VERSION

These examples are generated using
 $ mailsend -V
mailsend Version: @(#) mailsend v1.17b11
Compiled with OpenSSL: OpenSSL 0.9.8x 10 May 2012
 

Show server info

 
$ mailsend -v -info -port 587 -smtp smtp.gmail.com
$ mailsend -v -info -ssl -port 465 -smtp smtp.gmail.com
$ mailsend -v -info -smtp smtp.example.com -ct 2

 

STARTTLS + AUTHENTICATION

 
 $ mailsend -to user@gmail.com -from user@gmail.com  
-starttls -port 587 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v  
-user you -pass "your_password"
 

SSL + AUTHENTICATION



 $ mailsend -to user@gmail.com -from user@gmail.com  
-ssl -port 465 -auth  
-smtp smtp.gmail.com  
-sub test +cc +bc -v  
-user you -pass "your_password"
 
As -auth is specified, CRAM-MD5, LOGIN, PLAIN will be tried in that order. Use -auth-cram-md5, -auth-plan, -auth-login for specific auth mechanism.
Note: Password can be set by env var SMTP_USER_PASS instead of -pass

 

Attachments

 
 $ mailsend -f user@example.com -smtp 10.100.30.1  
-t user@example.com -sub test -attach "file.txt,text/plain"  
-attach "/usr/file.gif,image/gif" -attach "file.jpeg,image/jpg"
 
 $ mailsend -f user@example.com -smtp 192.168.0.2  
-t user@example.com -sub test +cc +bc  
-attach "c:\file.gif,image/gif" -M "Sending a GIF file"
 
 $ mailsend -f user@example.com -smtp 192.168.0.2  
-t user@example.com -sub test +cc +bc -cs "ISO-8859-1"  
-attach "file2.txt,text/plain"
 

Inline Attachment

 
 $ mailsend -f user@example.com -d example.com -smtp 10.100.30.1  
-t user@example.com -sub test -attach "nf.jpg,image/jpeg,i"  
-M "body line1: content disposition is inline"  
-M "body line2: this is line2 of the body"