#!/bin/bash
# Basé sur un travail de Cédric Abonnel / Cédrix sous licence CC BY-NC 4.0

POSTFIX_ALIASES="/etc/postfix/virtual_aliases"

if [[ -z "$1" || -z "$2" ]]; then
    echo "Usage: $0 <alias> <cible>"
    exit 1
fi

ALIAS=$1
TARGET=$2

echo "$ALIAS $TARGET" >> $POSTFIX_ALIASES

postmap $POSTFIX_ALIASES
systemctl reload postfix

echo "Alias $ALIAS ajouté vers $TARGET 🎉"
