This simple little command-line mailer compiled cleanly on Mac OS X Panther, and RPM's etc. are available at the web link.
This is strictly for sending mail. It can work through your systems SMTP server, some external server, or you can specify a particular server on the command line: that can be very handy. Real MIME attachments can be attached, and it can use GPG for encryption or signing.
For some reason I didn't investigate, "make install" didn't work, so I just did it by hand:
sudo ./install-sh --bindir /usr/local/bin --sysconfdir
/usr/local/etc --mandir /usr/local/man --binext '' --version
"2.2.2" --docdir /usr/local/doc
See also: GETTING A MAC TO "PHONE HOME" WITH AN E-MAIL
I find this quite useful on my Mac for quickly sending files without bothering to get into Mail.app, find the file, attach it..
(Article continues after the break)
email [options] recipient1,recipient2,...
-h, -help module Print this message or specify one of the below options
-q, -quiet Suppress displayed messages (Good for cron)
-f, -from-addr Senders mail address
-n, -from-name Senders name
-b, -blank-mail Allows you to send a blank email
-e, -encrypt Encrypt the e-mail for first recipient before sending
-s, -subject subject Subject of message
-r, -smtp-server server Specify a temporary SMTP server for sending
-p, -smtp-port port Specify the SMTP port to connect to
-a, -attach file,... Attach N binary files and base64 encode
-c, -conf-file file Path to non-default configuration file
-t, -check-config Simply parse the email.conf file for errors
-cc email,email,... Copy recipients
-bcc email,email,... Blind Copy recipients
-sign Sign the email with GPG
-html Send message in HTML format ( Make your own HTML! )
-u, -smtp-user Specify your username for SMTP AUTH
-i, -smtp-pass Specify your password for SMTP AUTH
-g, -gpg-pass Specify your password for GPG
-high-priority Send the email with high priority
The man page is better than many:
EMAIL(1) EMAIL(1)
NAME
email - Encrypted SMTP email via Command line
SYNOPSIS
email [options] recipient1,recipient2,recipient3,...
DESCRIPTION
Email is a command line email client similiar to 'mailx'. Added fea-
tures make this a more advanced client for sending email via the com-
mand line. Email works with sendmail, just as 'mailx' does, but email
also allows sending to remote smtp servers for your email delivery. It
also works with GPG for encrypting and signing the emails on the fly.
Email also incorporates a few other features as well. These features
include signature files with wildcard options to specify the data,
time, day, version, system, and even a 'fortune' with the help of the
'fortune' command. Email also supports a very configurable address
book. This way you can specify a persons name with an email address
and also place a group of names into one group for sending.
Email also support attachments. It will accept N attachments via a
command line option and encode them with Base64 before sending them
with the email.
Email works with a configuration file named email.conf which is found
in /usr/local/etc/email/email.conf although can be changed by specify-
ing the --sysconfdir option during the ./configure. If you do not have
or want a configuration file, you can specify the -r option to specify
your smtp server and this will allow you to bypass using a configura-
tion file and use default values. If you specify the -r option (listed
below) and you do have a configuration file, it will still use the con-
figuration file but override the SMTP_SERVER variable with what is used
at the command line.
OPTIONS
There are a few possible options to email. I have listed them in order
of relevance of usage:
--help , -help , -h Module of Help
This option can be specified with a module of help topic, or
without one. Without a module of help topic, it will just print
a standard help screen with all your possible options. With a
module of help option, it will display a more detailed discrip-
tion of that module.
Modules are determined by command line switches. For instance:
if you want to know about the 'encrypt' command line option, you
would specify --help 'encrypt' or --help 'e' and help will dis-
play the correct module help section.
The Help is not statically programmed into email. Instead it is
a file in email's home directory called be rewritten with every
release of email.
--quiet, -q
This option will allow you to suppress the output of email.
Email will normally be verbose with it's messages to the screen
detailing its process in sending the mail ( i.e. a progress bar
is displayed). If you are using email in cron jobs, it is a
good idea to use this option so that no output, except for
errors, are displayed.
--blank-mail, -blank-mail, -b
Use this option if you would like to send a blank email from the
command line. This is good if you just want to send a message
with only the headers and no content.
--subject , -subject , -sub , -s Subject of Email
This option should be rather obvious. You specify the subject
of the email with this option. If you are not redirecting to
standard input and you do not specify a subject, email will ask
you for the subject. Null subjects are allowed.
--encrypt , -encrypt , -e
This options allows you to encrypt your email message using
'gpg'. GPG can be obtained by going to: When this option is
specified, it will get the first recipient from the recipient
list and it will encrypt the message using their key. This key
MUST be present in order for the encryption to work properly.
--sign , -sign
This options will let you sign your emails on the fly... It uses
the 'gpg --detach-sign' option. It will 'sign' the email with
your public key.
--cc , -cc recipient1,recipient2,recipient3,...
This option allows you to "curtosy copy" a list of recipients.
Recipients can be from the address book or just plain email
addresses. They should be comma delimited just as the main
recipients will be. CC recipients *will* be posted in the head-
ers and read by email clients.
--bcc , -bcc recipient1,recipient2,recipient3,...
Same as the --cc option, but these recipients will *not* be
posted in the headers of the email. This is a positive solution
to "secretly" copy someone on the email without the other recip-
ients knowing so ( Managers usually bcc their boss when sending
an email to you about your performance and you'll never know it
;-) )
--attach , -a file1,file2,file3,...
Attach a binary file. This option will allow you to attach N
files to your email and will be base64 encoded upon delivery.
This option is helpful if you need to send any type of file that
is not plain ascii text.
--smtp-server , -r server
This option will let you override the smtp server that is speci-
fied in the email.conf file... You can use this option if you do
not have an email.conf file. It will allow you to use email
without a configuration file. A helpful option to add with this
option would be the --smtp-port option, however, it is not
needed.
--smtp-port , -p port
This option works well with the above option as it will allow
you to bypass the configuration file and specify a port on the
command line. This is helpful if you don't have a configuration
file yet need to specify an smtp server and a port. The default
port is always port 25, so that if you don't specify this
option, and you don't have an email.conf file, it will default
to port 25 for you.
--smtp-user , -u user
If you don't want to keep your SMTP username in your email.conf
file (SMTP_AUTH_USER), then you can use this command line option
to specify it.
--smtp-pass , -i pass
If you don't want to keep your SMTP password in your email.conf
file (SMTP_AUTH_PASS), then you can use this command line option
to specify it.
--from-name , -n name
This option will override MY_NAME in email.conf. This is what
the recipient will see in the from field of their email client.
--from-addr , -f addr
This option will override MY_EMAIL in email.conf. This is what
the recipient will see in the from field of their email client
as your email address.
--conf-file file
Use this option to specify a configuration file other than
~/.email.conf or /usr/local/etc/email/email.conf.
--high-priority , -o
This options allows you to take advantage of using the priority
option used by some email clients. If the option is specified
when sent to a user using MS Outlook, a small exclimation mark
will be next to the message as to let the user know this email
is important.
--html This option allows you to send html emails. As of right now, you
need to write your own html. In later versions of email, it
will make your html for you... This is not a high priority
issue though, so we will take our time on it. ( Being as the
lead developer *hates* html emails being sent to him... Ugh...
)
--gpg-pass , -g pass
If you don't want to keep your GPG password in your email.conf
file (GPG_PASS), then you can use this command line option to
specify it.
CONFIGURATION
Configuration of email is fairly simple. Just open the default config-
uration file. If you did not specify an email home directory during
your compilation of email then this will be in /usr/local/etc/email and
the file is called 'email.conf'. The configuration options are listed
below.
SMTP_SERVER : Server name, or IP
SMTP_PORT : Servers port number
SENDMAIL_BIN : Specify the sendmail binary path and options
MY_NAME : Specify your Name
MY_EMAIL : Specify your email address
REPLY_TO : Seperate reply to address
SIGNATURE_FILE : Your signature file
SIGNATURE_DIVIDE : A design for a divider
ADDRESS_BOOK : Location of your address book file
SAVE_SENT_MAIL : Directory to save email.sent file
GPG_BIN : Full path to gpg binary
GPG_PASS : Optional passphrase for gpg
TEMP_DIR : Specify where to store temp files
SMTP_AUTH : Specify what type of authentication
for your smtp server.
SMTP_AUTH_USER : Specify a username login for SMTP AUTH
SMTP_AUTH_PASS : Specify a password for SMTP AUTH
You can choose to use sendmail instead of a remote smtp server. All
you have to do is input the path of where you have sendmail located in
the SENDMAIL_BIN variable. You may also provide options to pass send-
mail. The best values for this would be /usr/lib/sendmail -t -i. If
you have both SENDMAIL_BIN and SMTP_SERVER uncommented and both have
values, then SMTP_SERVER will take presedence over SENDMAIL_BIN and
'email' will try to contact the SMTP server provided.
You can create your own email.conf file in your home directory. It
must be a hidden file. For instance: ~/.email.conf
Email will look in your home directory before it looks for a global
configuration file. The easiest thing to do is simply copy your global
config file to your home directory as .email.conf and edit it as
needed.
If you do not have a global config file or a personal config file,
email will choose defaults according to your current login on the sys-
tem. So a configuration file is not manditory, it just helps you cus-
tomize email.
You can look at the basic configuration file for more information on
the configuration of 'email'.
SMTP AUTH
Email now support SMTP AUTH. I will briefly describe how it works
here.
To use email with an SMTP server that expects authentication you must
set a few options in your email.conf file. These options are:
SMTP_AUTH, SMTP_AUTH_USER, SMTP_AUTH_PASS.
SMTP_AUTH:
This option must be set to one of the two: LOGIN or
PLAIN. LOGIN and PLAIN are standard RFC compliant SMTP AUTH
protocols. If you are unsure which options to choose,
ask your ISP or SMTP Administrator if any of these are
supported. Usually it's a safe bet to use LOGIN for
SMTP AUTH. Most AUTH servers support LOGIN.
SMTP_AUTH_USER:
If you're using SMTP AUTH, please specify your username
here. This option is MANDITORY if you're using SMTP AUTH.
SMTP_AUTH_PASS:
You can choose to set this option or not. However, if
you don't set this option, email will prompt you for your
password before proceeding. So if you're using email from
a cron job and don't expect any interaction with email,
please set this option!
ENVIRONMENT VARIABLES
Two environment variables can be set that email will check.
EDITOR will allow you to specify your favorite editor to use with email
for constructing messages. If this variable is not set, it will default
to vi.
TMPDIR can be set to specify a temporary directory to place your temp
files while email is working. This is analogous to the TEMP_DIR vari-
able in email.conf. environment variable TMPDIR for a temporary direc-
tory. If neither contains a value, email defaults to /tmp.
ADDRESS BOOK
The address book for email takes on the format as described below. It
will check for any syntax errors in the address book and completely
stop email if it finds any, so try to keep the same gramatical syntax.
A single entry in the address book will look like:
single: Dean = dean@cleancode.org #Comments allowed
You are welcome to use a whole name with spaces as long as you use a
single quote closing the name with another single quote. You may also
use double quotes in place of the single quotes. Example:
single: 'Dean Jones' = dean@cleancode.org
Groups are allowed and can only consist of comma delimited single
entries from the file and may contain spaces. You can *not* recur-
sively specify groups. You may, however specify single email addresses
that are not part of the address book.
If you would like to break one line into two lines, you should use the
'\' as a newline escape mark. Examples:
group: Mygroup = 'Dean Jones', John, Sam, Bob, \
software@cleancode.org
This example will specify a group with the single entries of 'Dean
Jones', John, Sam, Bob, and the unadded email address of 'soft-
ware@cleancode.org'.
SIGNATURE FILE
The signature file is specified in the configuration file. You will
also have the option to specify a signature divider. This is by
default '---'. This just divides the signature file from the rest of
the email.
There are a few wild cards that you can specify in writing your signa-
ture file that will allow your signature file to obtain dynamic options
when sending your email.
%v This will show the version of email
%t This will show the time the email was sent
%d This will display the date the email was sent
%c This will display a completely formated date and time
%h This will display the host type
%f This will display the output of the 'fortune' command
SIGNATURE EXAMPLE
Example of a signature file is below:
This email was sent with 'email %v'
Sent on host: %h
At the time : %c
Your fortune for today is:
%f
This will end up replacing the %v, %h, %c, and %f with their corre-
sponding equivalents above respectively.
EXAMPLES OF USAGE
# Redirect your message to email
email -s "Sending this.txt" dean@cleancode.org < this.txt
# Make your message with email
email -s "Subject" dean@cleancode.org
# Encrypt and email to "Dean Jones"
email -s "Encryted" -encrypt dean@cleancode.org
# Multiple Recipients from address book
email -s "no subject" Dean,Jeff,Tom,Bob -cc Josh,Carl
# Attach some files with your message
email -s "files attached" Dean,Jeff --attach
stuff.tar.gz,readme.doc
BUGS
They're those little things that make you cringe when you find them in
your bed ( or program ) at 3 am.
If you find any in this program, please submit them to software@clean-
code.org
AUTHORS
Dean Jones - dean@cleancode.org
There may be a Sco binary at www.systemjanitor.com/sco_email/
Nope - long gone. But try this perl script as an alternate: sendEmail-v1.56
More Articles by Tony Lawrence - Find me on Google+ 2003-11-01
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
I am a Kerio reseller. Articles here related to Kerio products reflect my honest opinion, but I do have an obvious interest in selling those products also.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar