Knowledge base

C++ submission API

C++ Submission API
The third of five

The C++ submission binding is the third of five in the chapter. Its 19 methods are the same set of capabilities as the C binding, only without the allocation, freeing and error query functions.

Three classes in three headers: submitter/Connection.hxx, submitter/Message.hxx and submitter/Recipient.hxx; on Linux they are in /opt/pmta/api/include.

An error is an exception, after which the object is unusable and is discarded. Connecting supports logging in with a login and password via the CRAM-MD5 mechanism, so the password is not sent over the network.

The main trap is continuing with an object after an error. Any exception makes the object unusable: retrying on it is pointless, the object is created anew and the message is submitted anew.
What the Hub does. Not used: the Hub submits messages over SMTP. The methods of this binding are useful as a list of what the submitting side can decide for a message.
Recommended values

Main methods:

Method What it sets
Connection::Connection server, port, optionally a login and password
Message::setVirtualMta the sending address for the message
Message::setJobId the job
Message::setEncoding the encoding of added data
Message::setReturnType what to include in a non-delivery report
Connection::submit submit the message
The headers, error model and methods come from the manual (§ 7.4). The selection of methods for the table is ours.
Example configuration
# a message through the C++ binding: connection, sender, sending address
Connection conn("127.0.0.1", 25);
Message msg("sender@example.com");
msg.setVirtualMta("vmta1");conn.submit(msg);
A sketch based on the manual’s method descriptions; recipients are added with addRecipient, content with addData.
yellow — — directive names, blue — blocks. They are highlighted the same way in the text of the card.
Compatibility
PowerMTA 6.0
described in the manual of this version · platform: any
The vendor does not state the first version for every directive — there is no note here. The name also appears in the 5.0 edition of the manual.
How to check on the node
Check that the binding headers are in place:
ls /opt/pmta/api/include/submitter/
The Connection.hxx, Message.hxx and Recipient.hxx files — the C++ binding is installed.
In the Hub
Cost of a mistake
safe: a wrong value breaks nothing
Scenarios
Connect a sending platform