--- /dev/null
+--- qmail-remote.c.org Mon Jun 15 19:53:16 1998
++++ qmail-remote.c Tue Apr 14 08:48:29 2015
+@@ -29,6 +29,11 @@
+ #include "timeoutread.h"
+ #include "timeoutwrite.h"
+
++#include <string.h>
++#include <fcntl.h>
++#include <sys/socket.h>
++#include <sys/un.h>
++
+ #define HUGESMTPTEXT 5000
+
+ #define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */
+@@ -44,6 +49,8 @@
+ stralloc host = {0};
+ stralloc sender = {0};
+
++int lmtpmode = 0;
++
+ saa reciplist = {0};
+
+ struct ip_address partner;
+@@ -86,6 +93,12 @@
+ it isn't in my control/locals file, so I don't treat it as local. (#5.4.6)\n");
+ zerodie(); }
+
++void temp_no_lmtp_so_long() { out("ZLMTP file can't open\n"); zerodie(); }
++void temp_no_lmtp_socketopen() { out("ZLMTP socket can't open\n"); zerodie(); }
++void temp_no_lmtp_open() { out("ZLMTP file can't open\n"); zerodie(); }
++void temp_no_lmtp_non_support_multircpt() { out("Zcurrent LMTP don't support multi rcpt...\n"); zerodie(); }
++
++
+ void outhost()
+ {
+ char x[IPFMT];
+@@ -224,7 +237,11 @@
+
+ if (smtpcode() != 220) quit("ZConnected to "," but greeting failed");
+
+- substdio_puts(&smtpto,"HELO ");
++ if (lmtpmode){
++ substdio_puts(&smtpto,"LHLO ");
++ }else{
++ substdio_puts(&smtpto,"HELO ");
++ }
+ substdio_put(&smtpto,helohost.s,helohost.len);
+ substdio_puts(&smtpto,"\r\n");
+ substdio_flush(&smtpto);
+@@ -239,6 +256,9 @@
+ if (code >= 400) quit("ZConnected to "," but sender was rejected");
+
+ flagbother = 0;
++ if (lmtpmode && reciplist.len != 1){
++ temp_no_lmtp_non_support_multircpt();
++ }
+ for (i = 0;i < reciplist.len;++i) {
+ substdio_puts(&smtpto,"RCPT TO:<");
+ substdio_put(&smtpto,reciplist.sa[i].s,reciplist.sa[i].len);
+@@ -338,6 +358,7 @@
+ int flagallaliases;
+ int flagalias;
+ char *relayhost;
++ struct sockaddr_un address;
+
+ sig_pipeignore();
+ if (argc < 4) perm_usage();
+@@ -357,7 +378,11 @@
+ if (relayhost) {
+ i = str_chr(relayhost,':');
+ if (relayhost[i]) {
+- scan_ulong(relayhost + i + 1,&port);
++ if (strcmp(relayhost + i + 1,"lmtp") == 0){
++ lmtpmode = 1;
++ }else{
++ scan_ulong(relayhost + i + 1,&port);
++ }
+ relayhost[i] = 0;
+ }
+ if (!stralloc_copys(&host,relayhost)) temp_nomem();
+@@ -380,7 +405,20 @@
+ ++recips;
+ }
+
+-
++ if (lmtpmode){
++ stralloc_0(&host);
++ if (host.len >= sizeof(address.sun_path) -1) temp_no_lmtp_so_long();
++ smtpfd = socket(AF_UNIX,SOCK_STREAM,0);
++ if (smtpfd == -1) temp_no_lmtp_socketopen();
++ address.sun_family = AF_UNIX;
++ strcpy(address.sun_path, host.s);
++ if (connect(smtpfd,(struct sockaddr *)&address,sizeof(address)) == -1) temp_no_lmtp_open();
++ smtp(); /* does not return */
++ close(smtpfd);
++ temp_noconn();
++ /* end program */
++ }
++
+ random = now() + (getpid() << 16);
+ switch (relayhost ? dns_ip(&ip,&host) : dns_mxip(&ip,&host,random)) {
+ case DNS_MEM: temp_nomem();