Alllow sending through relayhost without authentication

Discussion in 'Tips/Tricks/Mods' started by AhmadShamli, Feb 29, 2024.

  1. AhmadShamli

    AhmadShamli New Member

    Hi,

    When sending email, sending domain matched relay_host in mail_domain database, postfix should send email through relay even the relay have no authentication.

    main.conf
    Code:
    smtpd_relay_restrictions =     permit_mynetworks,permit_sasl_authenticated, check_sender_relay_auth, reject_unauth_destination
    check_sender_relay_auth =     permit_auth_destination, permit_sasl_authenticated, permit
    
    mysql-virtual_sender-relayauth.cf
    Code:
    user = user
    password = password
    dbname = dbname
    hosts = 127.0.0.1
    query = SELECT CONCAT(relay_user,':',relay_pass) as credential
      FROM mail_domain
      WHERE domain = '%d'
      AND active = 'y'
      AND relay_host != ''
      AND concat(relay_user,relay_pass) != ''
      AND server_id = 1
    
    systemctl restart postfix

    This is when I have to use smtp-relay.gmail.com but always getting sasl auth error.
    Only do this if there is only you using the server, if there are others using it, they may add the same relayhost for their domain and bypass the authentication, and may affect your google account.

    Thanks
     
    ahrasis likes this.
  2. Hostking

    Hostking New Member

    This is dangerous - I wouldn't recommend anyone do this in todays time. Authentication should be bare minimum
     
    BrettP-, Th0m and ahrasis like this.

Share This Page