Permalink
Switch branches/tags
Find file Copy path
8d63c07 May 28, 2018
@muquit @theclickman @sergeevabc
95 lines (73 sloc) 3.22 KB

Table of Contents

Show server info

  mailsend -v -info -port 587 -smtp smtp.gmail.com
  mailsend -v -info -ssl -port 465 -smtp smtp.gmail.com

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"
  Note: Password can be set by env var SMTP_USER_PASS instead of -pass

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

One line messages

One line messages are specified with -M. Each message can have its own MIME type, character set and encoding type (requires mailsend v1.17b15+):

  mailsend -f user@example.com -smtp 10.100.30.1
  -t user@example.com -sub "testing oneline messages"
  -cs "us-ascii"
  -enc-type "7bit"
  -M "This is a test"

  -cs "iso-8859-1"
  -enc-type "8bit"
  -M "Das Vetter ist schön!"

  -cs "Big5"
  -enc-type "base64"
  -M "中文測試"

Attachments

Only requirement of -attach is the path of the file. All other attributes can be specified before -attach with appropriate flags. Note: The flags must be specified correctly for each attachment, otherwise the one specified in previous attachment will be used.

By default, MIME type is guessed from filename extension, default encoding type base64 is used:

  mailsend -f user@example.com -smtp 10.100.30.1
  -t user@example.com -sub "this is a test"
  -attach "file.pdf" -attach "file.jpg"

But all aspects of attachments can be controlled (requires mailsend v1.17b15+)

  mailsend -f user@example.com -smtp 10.100.30.1
  -t user@example.com -sub test
   -mime-type "text/plain"
   -enc-type "7bit"
   -charset "us-ascii"
   -attach "file.txt"

   -enc-type "8bit"
   -charset "iso-8859-1"
   -attach "deutsch.txt"

  -mime-type "image/gif"
  -enc-type "base64"
  -aname "flower.gif"
  -attach "/usr/file.gif"

  -mime-type "image/jpeg"
  -enc-type "base64"
  -attach "file.jpeg"

By default, content disposition of all attachments are attachment, use -disposition "inline" to give hint to the mail reader to display it as mail body. Look at FAQ# 1 for details.

Including a body

Only one file can be included as a body of the mail. If the file is not us-ascii, the SMTP server has to support it. If you include a binary file, result is undefined. Requires mailsend v1.17b15+

  mailsend -f user@gmail -t user@example.com -smtp smtp.gamil.com
   -port 587 -starttls -auth -user user@gmail.com -pass secret
   -charset "utf-8"
   -mime-type "text/plain"
   -msg-body "file.txt"

If you want to include attachments and a body, you must provide the body as inline attachment:

   -mime-type "image/gif"
   -enc-type "base64"
   -aname "flower.gif"
   -attach "/usr/file.gif"
   
   -mime-type "text/plain"
   -disposition "inline"
   -attach "file.txt"