Adding to email domains list ..Mail for domain failed! : SQL insert failed : Duplicate entry '' for key 'PRIMARY' at /usr/share/webmin/web-lib-funcs.pl line 1433

Hi I am trying to enable Mail for one of the domain in Virtualmin but I got error: Mail for domain failed! : SQL insert failed : Duplicate entry '' for key 'PRIMARY' at /usr/share/webmin/web-lib-funcs.pl line 1433

Please advice. Kind regards Marko

Status: 
Active

Comments

Howdy -- hmm, are you by chance using MySQL for storing usernames/passwords?

Or are you using the standard Linux /etc/passwd files for that?

Also, do you have Postfix setup to store mail aliases in MySQL?

Hi, yes, I am using MySQL for storing data as in postfix main.cf: virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_domains.cf virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf relay_domains = proxy:mysql:/etc/postfix/mysql_relay_domains.cf

since I was and still can adding domains and users etc. with postfix.admin (http://postfixadmin.sourceforge.net/)

Can you post the contents of those .cf files that you use to configured Postfix to talk to MySQL?

Virtualmin tries to parse them to work your table structure, but I suspect it is going wrong.

Hi JamieCameron, .cf files are:

"mysql_virtual_mailbox_domains.cf" :
hosts = 127.0.0.1 user = someusername password = somepassword dbname = postfixadmin query = SELECT domain FROM domain WHERE domain='%s' and backupmx = 0 and active = 1

next:
"mysql_virtual_mailbox_maps.cf":
hosts = 127.0.0.1 user = someusername password = somepassword dbname = postfixadmindb query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1

next:
"mysql_virtual_alias_maps.cf":
hosts = 127.0.0.1 user = someusername password = somepassword dbname = postfixadmindb query = SELECT goto FROM alias WHERE address='%s' AND active = 1 table = alias select_field = domain where_field = active

next:
"mysql_relay_domains.cf":
hosts = 127.0.0.1 user = someusername password = somepassword dbname = postfixadmindb query = SELECT domain FROM domain WHERE domain='%s' and backupmx = 1

I think the problem is that active field - do you have multiple entries in the alias table for the same address but with different active values?