• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I need a Java package that can receive SMTP traffic

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing a package that sits in front of our primary SMTP server (Postfix) that will route mail either to localhost or another SMTP server based on the sender address. We have two outgoing servers. One handles most all of our outgoing traffic and the other is configured especially to talk to Mandrill, a mailing service of MailChimp. The latter server handles all outgoing traffic originating in our admissions office (aka, the higher ed marketing). The bulk of the mail is generated out of the admissions database that points to this secondary SMTP server. My problem is that admissions counselors often do large mailings through their individual email accounts, so I would like to select the SMTP server to route the mail based on the sender address (which can be looked up easily in LDAP).

I'm familiar with JavaMail for sending mail from programs and I also use it for managing restricted exploder lists as I can check on whether a sender is authorized to send email to that list. But the content is either generated from another program or in the case of exploders, the content is fed in through STDIN. But as far as I know, JavaMail can send but cannot receive mail over SMTP. Are you aware of any package that might meet my needs?

Thanks,

Rob Tanner
Linfield College
 
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Tanner wrote:I'm writing a package that sits in front of our primary SMTP server (Postfix) that will route mail either to localhost or another SMTP server based on the sender address. We have two outgoing servers. One handles most all of our outgoing traffic and the other is configured especially to talk to Mandrill, a mailing service of MailChimp. The latter server handles all outgoing traffic originating in our admissions office (aka, the higher ed marketing). The bulk of the mail is generated out of the admissions database that points to this secondary SMTP server. My problem is that admissions counselors often do large mailings through their individual email accounts, so I would like to select the SMTP server to route the mail based on the sender address (which can be looked up easily in LDAP).

I'm familiar with JavaMail for sending mail from programs and I also use it for managing restricted exploder lists as I can check on whether a sender is authorized to send email to that list. But the content is either generated from another program or in the case of exploders, the content is fed in through STDIN. But as far as I know, JavaMail can send but cannot receive mail over SMTP. Are you aware of any package that might meet my needs?

Thanks,

Rob Tanner
Linfield College



I've never used it myself so can't vouch for it, but a quick search found SubEthaSMTP. Is this suitable for your needs?
 
Rob Tanner
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another member of the forum suggested that I look at SubEthaSMTP and it looks like it will fit the bill (thanks Mike).

I downloaded the code, built the example from the WIKI (below), added the required jars to my path in Eclipse, added some print statements to display the sender and recipient’s email addresses, and started it up. And I also surrounded the for loop with a while loop to keep it looping indefinitely otherwise it simply falls through and stops. It should according to the explanation on the Wiki page, be listening on port 2500, but when I try to connect everything just times out as if it’s not even listening (if it makes any difference, my Java development is a Mac running Mavericks).

This code is exactly like what's shown in the wiki other than I added the infinite while loop:


Anybody have any ideas because right now I can't even get to first base.

Thanks,

Rob Tanner
Linfield College
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked to see if you can use a MTA like sendmail and configure it to select the appropriate smarthost based on the sending domain?
 
Rob Tanner
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sadly, my issue isn't domain specific, it's department specific and everyone is in the same network domain. I need to be able to route all outgoing messages that originate from folks who work in the Admissions office (the marketing division of colleges and universities) to a server that talks exclusively to a re-mailing service where Auth-SMTP is used as part of the handshake. Since every individual with a campus email account has an LDAP entry as well, I need that entry to discover their departmental affiliation and route the message to one server or the other based on that affiliation. I can use Javamail to route the message but I also need some way to receive it.
 
Ron McLeod
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't looked at this in a long time, but Sendmail or other MTAs have support for milters (external mail filters) which will can be called at various points in the message processing to make handling decisions . You should be able to hook-in and see the MAIL FROM, RCPT TO, client IP address, and other information that you may need to make your routing decision.

There is an open source project called sendmail-jilter which might be worth looking at - I have never used it.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any reason you are doing this in Java? It seems like you need a basic SMTP proxy. There has to be atleast a thousand solutions out there.. and maybe your existing firewall/proxy might have a solution inbuilt

Or if you want something that integrates with Java, you might want to look at Apache James. It's a collection of modules that collectively provide email server functionality. There will probably me something for a SMTP proxy there.
 
Rob Tanner
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it doesn't have to be done in Java. Any package that can to an LDAP search, find the user, retrieve the LDAP entry and make a decision based on department affiliation will do. But if I'm having to write it, it will be in Java.
reply
    Bookmark Topic Watch Topic
  • New Topic