Howto configure Sender dependent relayhost with auth on 587 port

Discussion in 'Installation/Configuration' started by DarioL, Jan 30, 2024.

  1. DarioL

    DarioL Member

    For a certain domain I need to configure a relay based on the sender.
    the remote relay server accepts connections on TLS port 587 + authenticates with user and password.
    On old postfix server I have configure and use the "sender_dependent_relayhost_maps" and "smtp_sasl_password_maps" options to redirect to external relay server all email with a specific domain sender.
    How I can do that with ISPConfig Version: 3.2.11p1 ?
    I have try to enable "System > interface > main config > mail > Show per domain relay options" and add this domain with right "host : port" + "user" + "pass", but if I try to send an email the user is looked for on local server and I get this error:
    postfix/smtpd.... NOQUEUE: reject: RCPT from ... Sender address rejected: User unknown in virtual mailbox table
    Many thanks for your help
    Dario
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    It seems that you added the recipient domain in ISPConfig as an email domain. Postfix will always try to deliver an email locally when you add the recipient's domain as a local email domain.
     
  3. DarioL

    DarioL Member

    I don't know exactly what I should do to activate this kind of relay, searching I found that tip and tried it, but do not work.
    How To I can configure this sender relay into ISPconfig ?
    Thank for reply
    Dario
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    You have to add the domain that you want to send with (sender domain) in ISPConfig under email > domain and there you enter the relay details. This then adds a sender_dependent_relayhost_maps config in postfix. But what you seem to have done according to the error message is that you either added the recipient domain instead of the sender domain or you used for testing a email recipient address of a local domain of your server instead of an external domain. As mentioned above, when you add a certain domain to postfix as local domain and you send an email to an address of this locally added domain, then postfix will always try to deliver that email locally and postfix will ignore the rely config in that case as a local domain has precedence over relaying.
     
  5. DarioL

    DarioL Member

    what I'm trying to do is send an email like this:
    The domain @dom.com it's not a my local domain, the recipients are stored on another server and I must relay all mail for @dom.com to a specific relay server on port 587 and user + password.
    On old server the domain dom.com is not configured under email > domain an I have route this kind of email configuring manually main.cf adding "sender_dependent_relayhost_maps=[1]" and "smtp_sasl_password_maps=[2]" with something like this:
    Code:
    [1]@dom.com [relay.server.com]:587
    [2]:[relay.server.com]:587  user:pass
    
    if I add this type of configuration to main.cf at the end of the existing parameters set by ispconfig, the email get out correctly via relay server.
    Code:
    sender_dependent_relayhost_maps = proxy:mysql:/etc/postfix/mysql-virtual_sender-relayhost.cf, hash:/etc/postfix/sender-relay-maps
    smtp_sasl_password_maps = proxy:mysql:/etc/postfix/mysql-virtual_sender-relayauth.cf, texthash:/etc/postfix/sasl_passwd, hash:/etc/postfix/sasl-passwords
    
    If possible, I'm looking for a solution without modify main.cf and configure this sender relay via ISPconfig control panel.
    I hope I was able to explain myself
    Many thanks for your patience
    Dario
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok. That's what can not work, as the sender and recipient domains are the same, and Postfix must always try to deliver that locally. What will work is:

    Code:
    From: [email protected]
    To: [email protected], ...
    [/QUOTE]

    but as soon as you add as recipient the same domain that you use as sender and where you added the relay settings for, then postfix must try to send it locally and this must fail as there is no mailbox [email protected] on this server. So either do not add [email protected] to the recipient list or add [email protected] as local mailbox.
     
    ahrasis likes this.
  7. DarioL

    DarioL Member

    Thank for reply, this clears my doubt:
    "Can I configure this specific scenario (sender depend only relay host) via the ispconfig control panel?"
    If I understand correctly the answer is NO.
    Unfortunately neither of the two proposals is usable for me.
    At this point, since ispconfig does not allow a only "sender depend relay host" mode, without necessarily having a local domain, the only solution for me is modify manually the mail.cf file and add another options to sender_dependent_relayhost_maps and smtp_sasl_password_maps, as I show in the previous my post.
    For now, this resolve my problem ... as long as a new "only sender relay" flag in the domain creation panel (or wherever you prefer) and another AND test into virtual_mailbox_domains mysql query will add.
    That, probably, will resolve this scenario.
    Many thanks.
    Dario
     
    Last edited: Feb 1, 2024
  8. DarioL

    DarioL Member

    Sorry, but IMHO this behavior is not correct.
    If I add a relay host for a domain I want forward always and all email to this relay server, both if the recipient is external and internal.
    it is probably wrong to load an external relay server where the internal domains are indicated, or the relay server must always be used, regardless of the recipient's domain.

    The final rule could be: If I use an external relay server for a domain, my server always have to forward all emails to that relay server because my server knows nothing about the mailboxes of that domain.

    What do you think about it?
    Thanks for reply
    Dario
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    The current behavior is exactly as we want it to be in ISPConfig. The case of using a domain-dependent relay on a system that is not a mail server for that same domain is quite rare. We will not add another option as people complain already that ISPconfig offers way too many options to configure a system, so we will not add another domain list for domain-dependent relay hosts. If you don't like that, you can configure that on your system manually.
     

Share This Page