diff --git a/README.md b/README.md index 48d98a32..d15901ea 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Download the docker-compose.yml, the .env and the setup.sh files: #### Create your mail accounts - ./setup.sh email add [] + ./setup.sh email add [] #### Generate DKIM keys diff --git a/target/bin/addmailuser b/target/bin/addmailuser index 8d881cb1..9e613c81 100755 --- a/target/bin/addmailuser +++ b/target/bin/addmailuser @@ -19,6 +19,7 @@ escape() { } [ -z "$USER" ] && { usage; errex "no username specified"; } +expr index "$USER" "@" >/dev/null || { usage; errex "username must include the domain"; } grep -qi "^$(escape "$USER")|" $DATABASE 2>/dev/null && errex "User \"$USER\" already exists" diff --git a/test/tests.bats b/test/tests.bats index 3a6a0ad0..47127846 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -1050,6 +1050,11 @@ load 'test_helper/bats-assert/load' # # accounts # +@test "checking accounts: user_without_domain creation should be rejected since user@domain format is required" { + run docker exec mail /bin/sh -c "addmailuser user_without_domain mypassword" + assert_failure + assert_output --partial "username must include the domain" +} @test "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf" { docker exec mail /bin/sh -c "addmailuser user3@domain.tld mypassword"