ubmail – send email from the command line


ubmail {–attach <file>{,<file>}} {–bcc <recipient>{,<recipient>}} {–cc <recipient>{,<recipient>}} {–content <content type>} {–debug} {–domain <optional masquerade domain>} {–extract <group>} {–file <filename>} {–header <filename>} {–help} {–nostdin} {–reply-to <recipient>} {–sender <optional sender email>} {–subject <message subject>} {–} <recipient>{,<recipient>}


ubmail is a command line utility to send simple and mime encoded email to a list of recipients.

ubmail can also be used to extract attactments from a mail message

ubmail determines the name of the sender by looking (in order) at the environment variable EMAIL_USER, the environment variable REMOTE_USER, and finally it uses the login user id to determine the sender.

Both ubcgi and ubupload set EMAIL_USER from the unibase.users file.


–attach name of file(s) to attach text attach one or more files to the message.
–bcc recipient list text blind copy message to recipient list
–cc recipient list text send copy to recipient list
–content mime type text mime type of message body. default type is text/plain.
–debug show communications with mailer
–domain text masquerade as this domain.

Use if the fqdn (fully qualified domain name) of the host is not where you want the email to come from.

NB this will not fool anti-relaying in mail servers

–extract extract group text extract mime attachments. Does not attempt to send email.

The output from this form of the command is a list of the mime attachment files

The files will be extracted to the current working directory.

A copy of the original email (including headers) is stored in /var/spool/ubmail/<group>. The name of the stored file is a date stamp (plus pid of the ubmail process).

NB no attempt is made to clean up the spool file. It is up to the application or system administrator to control the contents of this directory.

–file file name text get message body from file instead of standard input
–help print usage message
–nostdin don’t try to read a message body from standard input. usefull if just attaching a file.
–reply-to email address text set the Reply-To: header in the message
–sender email address text set the From: header in the message.
–subject message subject text set the message subject
optionally mark end of flags. used if a reciptient name could be confused with a flag.


file not found (2) if an attachment doesn’t exist


date | ubmail –subject “TODAY’S DATE” friend@somewhere.com

ubmail –attach image.jpg –nostdin –subject “HOLIDAY SNAP” friend@somewhere.com

FILES=`ubmail –extract incoming`


Leave a Reply