MailerQ Client

MailerQ Client is a program that can be used to inject emails into RabbitMQ from the command line. The utility reads MIME from standard input and posts the message to the specified rabbitmq outbox. It is intended to be an alternative for command line utilities like "sendmail" to inject mails into your mail stack.

It is important to note that this can not be directly connected to MailerQ yet. It currently needs some custom middleware to convert the published message into the JSON format that MailerQ can read.

MailerQ mime output

Installation

The application is stored in our APT repository. If you have already enabled our APT repository, you can install it with this command:

sudo apt install mailerq-client

Configuration

All options can be supplied in the system wide config file, via environment variables and as command line options. The config file is stored in /etc/mailerq/client.txt. Options from the config file can be overridden by passing them as command line arguments or environment variables. The "rabbitmq-address" setting, for example, can be provided in the following ways:

We use "rabbitmq-address" as an example. All configuration settings can be supplied in a similar manner.

Supported options for RabbitMQ

The application reads MIME from standard input, and publishes it to the specified outbox queue, where they can be picked up by MailerQ.

The value of rabbitmq-outbox can also be formatted as "exchange:routingkey". If you use this format, all messages published to the specified exchange with the specified routing key are consumed.

Recipients

The recipients of the email can be specified by passing them in the command line arguments:

$ mailerq-client recipient1@example.com recipient2@example.com

Recipients can also be extracted from the email headers. MailerQ-Client parses the To, CC, and BCC headers from the provided MIME and stores them as a comma-separated list in the recipients AMQP header. MailerQ then sends the email to all recipients listed in this header. This behavior can be enabled using the --extract-recipients command-line option:

$ mailerq-client --extract-recipients

End of message

MailerQ Client reads in all data from standard input until it encounters a line with a single dot on it. It treats this line as the end-of-message marker and publishes all data up to this dot (but not including the dot) to the outbox message queue. This is the same behavior as "sendmail" and allows you to use MailerQ Client as drop-in replacement for sendmail.

This behavior could however be problematic if your email contains lines that start with a dot. Such lines should of course not be treated as end-of-message markers. There are two ways to prevent this; you can either stuff those lines with an extra dot in front. MailerQ Client will automatically recognize this and removes the extra dot, or you can add the command line option "--ignore-dot" to instruct MailerQ Client that dots do not have a special meaning, and that the message is ended with end-of-file instead.

$ mailerq-client --ignore-dot recipient1@example.com recipient2@example.com
$ mailerq-client --ignore-dot --extract-recipients

Envelope address

The envelope address that MailerQ Client uses for sending out an email is automatically extracted from the message MIME. It can be set in the custom "x-mq-envelope" header, or in the "return-path", "sender" or "from" header (in that specific order). However, you can also set the envelope address manually with the "--envelope" command line option:

$ mailerq-client --envelope myaddress@mydomain.com --extract-recipients

Sending emails from file

You can use regular unix shell pipes and I/O redirection operators to get the contents from a file into MailerQ.

$ cat email.txt | mailerq-client --extract-recipients --ignore-dot
$ mailerq-client --extract-recipients --ignore-dot < email.txt