0

I need to implement an intelligent mailing list/relay (on Linux). The idea is that:

  1. The server receives emails to a list address
  2. It parses the mail, and confirms that it's from a trusted source
  3. It looks up a list of recipients in a local database
  4. It does some minor processing on the incoming mail, and sends it out to the list
  5. It returns any bounce messages to the original sender

The server already has sendmail installed, but I can use another MTA if necessary.

This sounds straightforward, and sendmail already has a database look-up capability. However, I don't think this is particularly flexible, and I don't want to give sendmail independent access to my database.

The closest I've come to an existing solution is E-MailRelay, which looks good, but I don't want the overhead of integrating it if I can avoid it.

I'd appreciate a sanity check on my Plan B before starting it, or alternative suggestions. I haven't found any useful docs on this and the Sendmail book doesn't seem to have anything relevant in it.

What I'm thinking about is:

  1. Implement an SMTP delivery agent for sendmail, and have sendmail and the DA running on the same server, with the DA listening on some unspecified port (which?)
  2. Sendmail presumably acts as an SMTP client when connecting to the DA, and my DA will respond to MAIL/RCPT/DATA commands
  3. The DA processes the received mail, which will be either a message out to the mailing list, or a bounce, or possibly a response
  4. The DA then switches to client mode, connects to sendmail, and issues MAIL/RCT/DATA commands to return the response to the original sender

Does this make sense? Thanks.

EML
  • 9,619
  • 6
  • 46
  • 78
  • Why would you reimplement this? You are describing Sendmail aliases. And if you want to develop something new, I would suggest targeting a modern MTA like Postfix instead. – tripleee Oct 23 '14 at 16:11
  • @tripleee: this is, I think, far more general than an alias. I could alias a list address using `:include:`, but that just references a static file, which I would need to separately maintain from my own database. And I couldn't do the mail processing. Or I could alias via `|` to an external program, but that just execs the program with the incoming mail on stdin, and I'd then have to exec sendmail myself with the response. That would be pointless - surely it's better to set up a socket? Besides, if I talk SMTP on a socket, I have a completely general solution, unrelated to sendmail. – EML Oct 23 '14 at 16:42
  • You are severely over-engineering this. Existing mailing list managers do a wonderful job. See e.g. http://www.gnu.org/software/mailman/ – tripleee Oct 23 '14 at 16:43
  • @tripleee: I've run several mailman lists in the past, and they're a PITA. Besides, it's not what I'm looking for. I have a webapp which is based on a MySql database, and the list addresses change frequently with the contents of the database. mailman is essentially static. I also have to *process* incoming messages, as I said, not just forward them on to a list. – EML Oct 23 '14 at 16:56

1 Answers1

0

This turned out to be pretty straightforward, although I didn't use a sendmail delivery agent - I just did everthing in SMTP. The server has two IP addresses, and sendmail is already listening on port 25 on IP#1.

I wrote an SMTP proxy which listens on port 25 on IP#2. This runs an SMTP server, which accepts incoming messages, and re-writes them. It then connects (as a client) to port 25 on IP#1, sending the re-written message to sendmail. sendmail then handles transmission to the re-written destination addresses. This is all transparent to the original mail client.

Not sure how I'd do this if the server only had one IP address, though.

EML
  • 9,619
  • 6
  • 46
  • 78
  • It would be fairly simple to implement this using only one IP address: Since one of the sendmail servers will be listening solely for messages being submitted by your application, you could just have it listen on a non-default port. – This isn't my real name Oct 30 '14 at 18:52