NixNet Mail/SQL Snippets

From NixNet

Before running any of these queries, make sure you run USE mailserver; to select the correct database.

Also make a backup before running any query just in case something goes wrong.

Addresses for RFC 2141

INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'info@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'marketing@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'sales@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'support@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'abuse@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'noc@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'security@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'postmaster@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'hostmaster@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'usenet@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'news@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'webmaster@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'www@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'uucp@example.com', 'john@example.com');
INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'ftp@example.com', 'john@example.com');

New alias

INSERT INTO virtual_aliases (domain_id, source, destination) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.com'), 'support@example.com', 'john@example.com');

New domain

INSERT INTO virtual_domains (name) VALUES ("example.org");

New user

INSERT INTO virtual_users (domain_id, email, password) VALUES ( (SELECT id FROM virtual_domains WHERE name='example.net'), 'john@example.net',CONCAT('{SHA256-CRYPT}', ENCRYPT ('insert_password_here', CONCAT('$5$', SUBSTRING(SHA(RAND()), -16)))));