diff --git a/bin/letsencrypt-certonly.sh b/bin/letsencrypt-certonly.sh index 3027e97..7659a5f 100755 --- a/bin/letsencrypt-certonly.sh +++ b/bin/letsencrypt-certonly.sh @@ -99,6 +99,28 @@ fi # copy above www subdomain section and modify as desired to # automatically check for and add additional subdomains to cert +# check common additional mail subdomains +if [[ $domain = mail.* ]]; then + # check for imap subdomain + dns=`host -t A ${domain/mail./imap.}|grep 'has address'|awk '{ print $4 }'` + if [[ " ${ips[@]} " =~ " ${dns} " ]]; then + command="$command -d ${domain/mail./imap.}" + dnscheck=true + fi + # check for smtp subdomain + dns=`host -t A ${domain/mail./smtp.}|grep 'has address'|awk '{ print $4 }'` + if [[ " ${ips[@]} " =~ " ${dns} " ]]; then + command="$command -d ${domain/mail./smtp.}" + dnscheck=true + fi + # check for pop subdomain + dns=`host -t A ${domain/mail./pop.}|grep 'has address'|awk '{ print $4 }'` + if [[ " ${ips[@]} " =~ " ${dns} " ]]; then + command="$command -d ${domain/mail./pop.}" + dnscheck=true + fi +fi + # check if any of the dns lookups passed if [[ "$dnscheck" = "false" ]]; then echo "All dns checks failed, can't create cert."