Error: Invalid Domain Format When Batch Creating Mail Domains

Hello, Community. I’m encountering a significant issue while attempting to batch-create email domains using the maildomain.sh script. The maildomain.txt file, generated on a Windows system with CRLF line endings, has resulted in an error for all added email domains:
Error: invalid domain format :: [domain=$'mydomain.com\r']

Currently, I am unable to access mydomain.com:8083/list/mail to delete these domains. Even trying the v-delete-mail-domains user command hasn’t produced any results.

I am looking for a solution without having to reinstall server. Any assistance you can provide with this matter would be greatly appreciated. Thank you.

#!/bin/bash
while IFS="," read -r user domain
do
    v-add-mail-domain "$user" "$domain"
done < maildomain.txt

Update: I tried restarting the server, but ran into a problem with nginx “Error: nginx restart failed.” As a result, all websites on my server are now inaccessible. This issue seems to resemble the one discussed in this thread

Hi @Decepticon,

Just edit your user’s mail.conf file and delete the affected mail domains:

/usr/local/hestia/data/users/YourUser/mail.conf

And you will see the affected domains, something like this:

DOMAIN='domain1.tld^M' ANTIVIRUS='no' ANTISPAM='yes' REJECT='no' DKIM='yes' WEBMAIL='' SSL='no' LETSENCRYPT='no' CATCHALL='' ACCOUNTS='0' RATE_LIMIT='200' U_DISK='0' SUSPENDED='no' TIME='18:56:50' DATE='2024-01-19'
DOMAIN='domain2.tld^M' ANTIVIRUS='no' ANTISPAM='yes' REJECT='no' DKIM='yes' WEBMAIL='' SSL='no' LETSENCRYPT='no' CATCHALL='' ACCOUNTS='0' RATE_LIMIT='200' U_DISK='0' SUSPENDED='no' TIME='18:56:51' DATE='2024-01-19'

So delete the entire line for the affected domains and save the file.

Now you should be able to access the mail list from Hestia Web UI but you also need to remove the created conf files inside this dir /usr/local/hestia/data/users/YourUser/mail/

Your affected domains will look like this:

ls -l /usr/local/hestia/data/users/YourUser/mail/
total 0
-rw-r--r-- 1 root root 0 ene 19 18:56 'domain1.tld'$'\r''.conf'
-rw-r--r-- 1 root root 0 ene 19 18:56 'domain2.tld'$'\r''.conf'

So delete them and all should be ok because I tested it and the command didn’t create any other dirs or conf files for these domains in the user’s home, neither exim or dovecot.

1 Like

@sahsanu Fantastic! Thank you for your assistance

P/s: I’ve deleted all mail/webmail domains, .conf files in home, exim, dovecot, nginx, etc., but the mail domain count (in the image) still shows 34. Could you guide me how to reset it to 0?

If you only did what you said in your first post, then you shouldn’t have any domain count in your mail section, also, no need to remove anything in nginx, dovecot or home because if you only ran the script in your previous post you shouldn’t have anything related to your mail domains there.

Anyways, as root, run this command to update the number of domains:

v-update-user-counters
1 Like

Thank you. It worked for me

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.