postfix send with multiple relays

Discussion in 'Server Operation' started by precipice8, May 24, 2017.

  1. precipice8

    precipice8 New Member

    Hi
    I need to set up 2 or more SMTP relays in postfix for sending out mail from a java program.
    For example the servers would be [smtp.office365.com]:587 and [smtp.gmail.com]:587 and the send addresses "email1AToffice365.com" and "email2ATgmail.com"
    How would I setup these 2 relays working together? And how do I then tell which relay/send address to use?

    Currently I manage to send out mail from these accounts separately by plain authenticating in the java program to postfix with a linux user "linuxuser1ATmyserver.com". But with 2 relays and 2 send addresses I need to somehow tell which relay to use.
    The java program cannot directly interact with [smtp.office365.com]:587, thus it needs to use a relay.
     
  2. ahrasis

    ahrasis Member

  3. precipice8

    precipice8 New Member

    Thank you. I've read that, but how do I tell which relay and send address to use? The java program authenticates to postfix as "linuxuser1ATmyserver.com"
     
  4. ahrasis

    ahrasis Member

    I think reply #2 in that post provides solution in the second example. I never tested that though, so I do not know whether that works.
     
  5. precipice8

    precipice8 New Member

    I think I may have got it working. Testing in the java webapp next
    main.cf:
    sender_dependent_relayhost_maps = hash:/etc/postfix/relayhosts
    relayhosts:
    mail1ATgmail.com [smtp.gmail.com]:587
    mail2AToffice.com [smtp.office365.com]:587

    Edit: Yes it also works in the java program
     
    Last edited: May 25, 2017
    ahrasis likes this.

Share This Page