#!/bin/bash

mailto="$1"
comment="$2"

vowels="aeiouy"
consonants="bcdfgjklmnprstvwz"
numbers="0123456789"
n_vowels=`echo -n $vowels | wc -m`
n_consonants=`echo -n $consonants | wc -m`
n_numbers=`echo -n $numbers | wc -m`

syllabes=$((RANDOM % 4 + 2))

str1=""

for f in `seq 0 $syllabes`
do
	str1+=${consonants:$((RANDOM % $n_consonants)):1}${vowels:$((RANDOM % $n_vowels)):1}
done

for f in `seq 0 $((syllabes - 1))`
do
	str2+=${numbers:$((RANDOM % $n_numbers)):1}
done

echo "Mail jetable : $str1-$str2@mateu.be"

echo "$str1-$str2: $mailto ($comment)" >> /etc/aliases
/usr/bin/newaliases
systemctl reload postfix

echo -n "" | mail -s "Votre nouvelle adresse temporaire pour $comment" $str1-$str2@mateu.be

