No top-level virtual servers selected

We needed to send notifications to each domain's owner by iterating the following CLI command :

virtualmin notify-domains --domain $dom --body-file /path/file.txt --subject "subject line" from noreply@hostname.tld

and it works fine for top-level domains, but when it comes to sub-domains it gives the error:

No top-level virtual servers selected

Sends email to some or all virtual server owners

virtualmin notify-domains [--domain name]
                          [--user login]
                          [--with-feature code]
                          [--without-feature code]
                           --body-file /path/to/file.txt | --body-stdin
                          [--charset cs]
                           --subject "subject line"
                          [--from user@domain]

I understand that subdomains belong to main domain's user and so they do not have their own contact e-mails, but then the above command should automatically take the respective top level domain's owner e-mail. Otherwise, it simply doesn't make sense how this command works with subdomains.

We will change our script now to (1) find the top level of each subdomain and then to extract and use it's owner's e-mail, but hopefully this request will be accepted soon and the above command will start working correctly as it is half baked in the current state.



Another thought: why to limit options to only

--body-file /path/to/file.txt | --body-stdin

and why not to add --body-string "string here" ?

We needed to notify about changes on each website to their owners and wanted to use $dom (domain name) in the body of the notification message. So for now we generate a file and then use the above format, however it would be very nice to compose the whole message in one line.

I tried all the possible combinations to get parent domain like:

virtualmin list-domains --domain sub.domain.tld --subserver
virtualmin list-domains --domain sub.domain.tld --toplevel
virtualmin list-domains --domain sub.domain.tld --subdomain
virtualmin list-domains --domain sub.domain.tld --parent
virtualmin list-domains --domain sub.domain.tld --parent sub.domain.tld
virtualmin list-domains --parent sub.domain.tld
virtualmin list-domains --subdomain sub.domain.tld

nothing seems to work.

So I had to use:

   file=$(virtualmin list-domains --domain $dom --file-only)
      parent=$(cat $file | grep backup_parent_dom)
      if [ ! -z $parent ]; then
      echo $dom

which seems pretty crazy.

You're right, the notify-domains API command should really support sending email to sub-servers. I'll fix this in the next release.

Status: Active » Fixed
Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Status: Closed (fixed) » Active

Was this ever really fixed? And if yes, then what about setting the message on the same command line? Why we have to use additional file with --body-file /path/to/file.txt | --body-stdin? Why there is no some option like --body-string "string here" ?

Because you can't really specify a multi-line email string via a command-line flag.

Please do not ignore the questions: was this ever fixed?

As for your reply, fair enough, however there are lot's of cases when users want to send just short notification message and it would be nice if API could do the same as most of server applications like PHP or bash can send a short e-mails with just one single line without making users to store messages on a separate file.

The original issue of notify-domains not sending email to sub-servers is fixed.

I'll add a --body-message flag in the next release to allow the body to be fully set on the command line.

Thanks, Jamie, that's great news!