<img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=lYCzn1QolK10N8" style="display:none" height="1" width="1" alt="">

QMQP

QMQP is less latency sensitive than SMTP. For single threaded injecting applications where network latency is the bottleneck, using QMQP instead of SMTP can increase injection speed.

Messages can be injected into GreenArrow Engine via QMQP using a QMQP client, such as the QMQP Sending Service described below

Introduction

The QMQP Sending Service provides a way to inject mail into a GreenArrow Engine installation from another server by invoking a local program that reads the email message from STDIN. This local program communicates with the GreenArrow Engine server using the QMQP network protocol. Messages are directly sent to GreenArrow Engine, rather than being queued on the server running the QMQP Sending Service.

One common scenario for sending email by invoking a local program is the mail() function in PHP. On Linux and UNIX, PHP’s mail() function invokes a local program, configured in the php.ini file. By using the QMQP Sending Service and properly configuring php.ini, the PHP mail() function can be made to queue mail into a remote GreenArrow Engine installation.

Other systems which send mail by invoking a sendmail binary, such as /usr/sbin/sendmail can also be use the QMQP Sending Service to send mail.

Definitions

  • QMQP Client - system running the QMQP Sending Service
  • QMQP Server - server running GreenArrow Engine

Requirements

  1. The QMQP Server must be setup on a GreenArrow Engine server. Contact GreenArrow Technical Support if you’d like this to be configured.
  2. The QMQP Server must be configured to accept email from the IP address of the QMQP Client. See the “Authorizing Relay Clients” section of this page for details on how to configure this.
  3. The QMQP Client must be able to make TCP connections to port 628 on one of the QMQP Server’s IP addresses.

Installation

  1. Run these commands on the QMQP Client:

    cd /usr/local/src
    wget http://calvin.drh.net/greenarrow-misc-files/greenarrow-qmqp-client-1.01.tar.gz
    tar xzf greenarrow-qmqp-client-1.01.tar.gz
    cd greenarrow-qmqp-client-1.01
    make
    make setup
    

  2. Place the hostname of the QMQP Client in its /var/hvmail-client/control/me file. For example:

    echo greenarrow.example.com > /var/hvmail-client/control/me
    

  3. Place the IP address of the QMQP Server in the /var/hvmail-client/control/qmqpservers file on the QMQP Client. For example:

    echo 1.2.3.4 > /var/hvmail-client/control/qmqpservers
    

Authorizing Relay Clients

To authorize a QMQP relay client, perform the following step on your GreenArrow Engine server:

  1. Add a new line to the /var/hvmail/control/qmqp.tcp file. For example, to authorize 1.2.3.4 as a relay client that uses SimpleMH, add:

    1.2.3.4:allow,GREENARROW_SIMPLEMH=""
    

  2. Activate changes to /var/hvmail/control/qmqp.tcp by running the following commands:

    cd /var/hvmail/control/
    tcprules qmqp.tcp.cdb qmqp.tcp.cdb.tmp < qmqp.tcp
    

See the IPs Authorized to Relay page for details on what environmental variables can be set in this file, and how to authorize ranges of IP addresses.

Testing

Run the command below, replacing recipient@example.com with the email address to send the test to:

date | /var/hvmail-client/bin/mailsubj "QMQP Sending Service Test Message" recipient@example.com

Sending Email

There are three interfaces used to send mail using the QMQP Sending Service:

sendmail Binary

The QMQP Sending Service comes with a sendmail compatibility interface that can be used by injecting applications designed to work with Sendmail. To use the sendmail interface, point the relevant portion of your application’s configuration to the following filesystem path:

/var/hvmail-client/bin/sendmail

Here’s an example command line invocation of sendmail:

`` ( echo From: newsletter@example.com ; echo To: recipient@example.com ; echo Subject: sendmail Test Message ) | /var/hvmail-client/bin/sendmail -t -i


### qmail-inject

The QMQP Sending Service comes with a `qmail-inject` compatibility interface that can be used by injecting applications designed to work with qmail. To use the `qmail-inject` interface, point the relevent portion of your application's configuration to the following filesystem path:

/var/hvmail-client/bin/qmail-inject

Here's an example command line invocation of `qmail-inject`:

( echo From: newsletter@example.com ; echo To: recipient@example.com ; echo Subject: qmail-inject Test Message ) | /var/hvmail-client/bin/qmail-inject

`qmail-inject` exits `0` if the message was successfully queued. It exits `100` if it was invoked improperly or if there is a severe syntax error in the message. It exits `111` for temporary errors.

Because the email message is being sent over the network before being queued, it is Highly Recommended that the sending application look for temporary errors and locally queue the message to be retired later. 

A full man page for `qmail-inject` is available here:
[http://www.qmail.org/man/man8/qmail-inject.html](http://www.qmail.org/man/man8/qmail-inject.html)

### mailsubj

The QMQP Sending Service comes with a `mailsubj` compatibility interface that can be used by injecting applications designed to work with qmail. To use the `mailsubj` interface, point the relevent portion of your application's configuration to the following filesystem path:

/var/hvmail-client/bin/mailsubj

Here's an example command line invocation of `mailsubj`:
date | /var/hvmail-client/bin/mailsubj “mailsubj Test Message” recipient@example.com

### Configuring PHP to use the QMQP Sending Service

PHP's `mail()` function can be configured to use `qmail-inject` by making the following entry in your PHP installation's `php.ini` file:

sendmail_path = /var/hvmail-client/bin/qmail-inject -H

Make sure to restart your web server so that the new PHP configuration is read.

### SimpleMH and Raw Injection Headers

[SimpleMH headers](/Injecting_Mail/SimpleMH_Injection/SimpleMH_Headers.md) and [Raw Injection headers](/Injecting_Mail/Raw_Injection/Raw_Injection_Headers.md) can be set the same way that they normally would be when injecting mail via SMTP.

Additionally, you can set the Mail Class of a message by setting the environment variable GREENARROW_MAILCLASS to the mail class identifier. For example:

( echo From: newsletter@example.com ; echo To: recipient@example.com ; echo Subject: qmail-inject Test Message ) | GREENARROW_MAILCLASS=transactional /var/hvmail-client/bin/qmail-inject

The QMQP Sending Service does not support setting VirtualMTA, SendID, and ListID using the `GREENARROW_MTAID`, `GREENARROW_SENDID`, and `GREENARROW_LISTID` variables.