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
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.
QMQP Client- system running the QMQP Sending Service
QMQP Server- server running GreenArrow Engine
- The QMQP Server must be setup on a GreenArrow Engine server. Contact GreenArrow Technical Support if you’d like this to be configured.
- 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.
- The QMQP Client must be able to make TCP connections to port
628on one of the QMQP Server’s IP addresses.
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
Place the hostname of the QMQP Client in its
/var/hvmail-client/control/mefile. For example:
echo greenarrow.example.com > /var/hvmail-client/control/me
Place the IP address of the QMQP Server in the
/var/hvmail-client/control/qmqpserversfile on the QMQP Client. For example:
echo 220.127.116.11 > /var/hvmail-client/control/qmqpservers
Authorizing Relay Clients
To authorize a QMQP relay client, perform the following step on your GreenArrow Engine server:
Add a new line to the
/var/hvmail/control/qmqp.tcpfile. For example, to authorize
18.104.22.168as a relay client that uses SimpleMH, add:
Activate changes to
/var/hvmail/control/qmqp.tcpby 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.
Run the command below, replacing
[email protected] with the email address to send the test to:
date | /var/hvmail-client/bin/mailsubj "QMQP Sending Service Test Message" [email protected]
There are three interfaces used to send mail using the QMQP Sending Service:
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:
Here’s an example command line invocation of sendmail:
### 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:
Here's an example command line invocation of `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:
Here's an example command line invocation of `mailsubj`:
### 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:
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:
The QMQP Sending Service does not support setting VirtualMTA, SendID, and ListID using the `GREENARROW_MTAID`, `GREENARROW_SENDID`, and `GREENARROW_LISTID` variables.