I am trying to make a postfix after-que content filter with a java program. I am having trouble reading the message as it comes into postfix with the java program I wrote. My java program listens on port 10025. When a new message comes into postfix, the java program successfully is “triggered/runs” and accepts the socket connection. The problem is that I cannot read an input stream to the socket. I would like to read the entirety of the e-mail message so I can filter parts of its content and make subsequent decisions before passing the filtered message back into postfix via port 10026. The java input stream simply does not have any data to read. I then terminate the java program, and I receive a “lost connection with 127.0.0.1[127.0.0.1] while receiving the initial server” error message via the “mailq” command. The new mail stays in my que.
Possible Problems (1 to 3): 1) I must write to the socket with an output stream. I would need to send appropriate SMTP traffic such as the example below. I tried writing a “220 smtp.server.com <http://smtp.server.com/>” Simple Mail Transfer Service Ready” command. Despite anything I send, I cannot read any data from the java socket even though a connection is made. 2) I do use TLS/SSL for my SMTP server. I may need to implement the certificates/key files into my java program. I would like to get an answer if the smtp(8) decrypts the sent traffic before sending it to the content filter? Please let me know. 3) I am missing how to “communicate” with the smtp(8) or local(8) that sends the e-mail message to my java program that listens on port 10025. Can I do with this socket programming and then can java open an input stream to read the e-mail message? ——Mail Que Error Message———— -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 0B3F76AC54D6B 1027 Thu May 14 17:52:22 [email protected] <mailto:[email protected]> (lost connection with 127.0.0.1[127.0.0.1] while receiving the initial server greeting) ——End of Mail Que Error Message———— —————postconf -Mf———————————— postconf -Mf postconf: warning: /etc/postfix/main.cf, line 112: overriding earlier entry: myorigin=$myhostname smtp inet n - n - 1 postscreen smtpd pass - - n - - smtpd dnsblog unix - - n - 0 dnsblog tlsproxy unix - - n - 0 tlsproxy submission inet n - n - - smtpd -o smtpd_tls_security_level=encrypt smtp unix - - n - - smtp pickup fifo n - n 60 1 pickup -o content_filter= cleanup unix n - n - 0 cleanup qmgr fifo n - n 300 1 qmgr tlsmgr unix - - n 1000? 1 tlsmgr rewrite unix - - n - - trivial-rewrite bounce unix - - n - 0 bounce defer unix - - n - 0 bounce trace unix - - n - 0 bounce verify unix - - n - 1 verify sacl-cache unix - - n - 1 sacl-cache flush unix n - n 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap relay unix - - n - - smtp -o smtp_fallback_relay= showq unix n - n - - showq error unix - - n - - error retry unix - - n - - error discard unix - - n - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - n - - lmtp anvil unix - - n - 1 anvil scache unix - - n - 1 scache dovecot unix - n n - 25 pipe flags=DRhu user=_dovecot:mail argv=/usr/libexec/dovecot/dovecot-lda -d ${user} policy unix - n n - - spawn user=nobody:mail argv=/usr/bin/perl /usr/libexec/postfix/greylist.pl —————End of postconf -Mf———————————— Rob Morton [email protected]
