[Warning: little off-topic] Re: API to write to lmtp directly

foobar foobar at intter.net
Wed Jul 9 05:21:48 EDT 2003


On Wed, 9 Jul 2003, Ramprasad A Padmanabhan wrote:

> Is there an API available with which I can directly write to lmtp
> instead of sending a mail
> I am presently using postfix and sending the mail, But I believe that
> calling an smtp agent has its own overheads.
> I am sending 10-15 messages to around 850 mailboxes every hour using
> postfix and aliases. The problem is there are too many lmtp processes
> and I get lmtp lock errors too often

Sorry I am going again off-topic (speaking about lmtp mainly here) and yes
I have one question too about "invalid headers" which is not off-topic ;)


Did you know that you can limit lmtp-processes in postfix (concurrency
etc) which makes mail to go slower .. without limits you could run into
these problems?

Anyways LMTP (Local Mail Transfer Protocol) specification is covered
pretty much by RFC2033 (http://www.ietf.org/).

If you are sending mass-mailings (like you said but didn't say it
directly) and you want to skip postfix:

PERL: install Net::LMTP (perl -MCPAN -e "install

--- ripped from perldoc Net::LTMP ---

#!/usr/local/bin/perl -w

           use Net::LMTP;

           my $lmtp = Net::LMTP->new('mailboxhost', 24);


           $lmtp->datasend("To: postmaster\n");
           $lmtp->datasend("A simple test message\n");

--- /ripped ---

Others, see rfc and make your own client for it. Remember if you are
delivering via unix-socket auth is not neccessary but in inetd-socket you
need it. LMTP is much smtp-a-like (atleast there is no EHLO/HELO (there
is LHLO) so it should be not too hard to write your own lmtp-client.

Maybe there is lmtp-injectors which you can use (I remember there was but
I don't remember).

Remember to use eval's and make it stable so you will not lose mails. I
understand there is unneccessary alias-lookups when mail is delivered via
postfix but you can always deliver directly into user. And remember to
insert headers correctly.

-- lmtp-transaction with Cyrus's lmtpd without AUTH --

220 foo.bar LMTP Cyrus v2.1.11 ready
LHLO foo.bar
MAIL FROM: <foobar at intter.net>
501 5.5.4 Syntax error in parameters
MAIL FROM:<foobar at intter.net>
250 2.1.0 ok
RCPT TO:<titus at foo.bar>
250 2.1.5 ok
354 go ahead

554 5.6.0 Message contains invalid header

^ Invalid headers, lets try again with one header:
(Somebody who knows rfc better than I, tell me what rfc said about header
parsing - is this "legal" to say invalid header here if no headers at

503 5.5.1 No recipients
MAIL FROM:<foobar at intter.net>
250 2.1.0 ok
RCPT TO:<titus at foo.bar>
250 2.1.5 ok
54 go ahead
From: foobar at intter.net

250 2.1.5 Ok


Btw, Net::LMTP didn't have any AUTH-related methods.

If you are not doing "direct-deliver" (mail is coming from outside)..
don't write your own MTA .. there is plenty of those already ;)

Maybe your overhead in the postfix is generated via 'deliver' wrappered
processes (fork per e-mail) which sucks, set transport to lmtp instead of
that pipe-wrapper if you are using it.

I hope this helped.


More information about the Info-cyrus mailing list