On 5/18/2015 7:12 PM, Robert Morton wrote: > 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.
If you configure postfix to use an SMTP content_filter, your program *must* speak SMTP; apparently it doesn't. > > 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. TLS will not be used between postfix and the content_filter unless you specifically enable it. > > 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? You should be able to find some example java SMTP servers on the web. Java programming details are off-topic here. > > ——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———— This is a normal error when the other end of the conversation does not support SMTP. -- Noel Jones
