Search code examples
javaauthenticationsmtphaproxy

create smtp authentication route with haproxy


Is it possible to insert username and authentication password in the haproxy route towards an smtp with authentication?

now I have a route like:

frontend SMTP bind *:25 mode tcp default_backend smtp backend smtp balance roundrobin mode tcp server vm3 smtp.domain.global:25 check

calling the route with a java job: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.3 Client was not authenticated

it is difficult for me to modify the java job now, while I would like to modify the haproxy configuration


Solution

  • As the pasted config looks a little bit odd let me format it.

    frontend SMTP
      bind *:25
      mode tcp
      default_backend smtp
    
    backend smtp 
      balance roundrobin
      mode tcp
      server vm3 smtp.domain.global:25 check
    

    Hope this makes now clear why it's not possible.
    HAProxy does not handle the SMTP Protocol, it just forwards the connection via TCP to the mail server therefore can't the SMTP Auth be injected nor done by HAProxy.