18

Is there something I can run from the command line that will let me query postfix (running locally)?

  1. if an address is in the virtual address file and,
  2. where the mail for that address is routed to.

Ex: If I have the email address of tim@domain.com. I want to ask postfix if that virtual alias exists and then see that it's mail get routed to tim11@mailserver.domain.com

Khaled
  • 36,533
  • 8
  • 72
  • 99
ckliborn
  • 2,778
  • 4
  • 25
  • 37

2 Answers2

22
sendmail -bv address@example.com

Despite the name, this is a Postfix program. This will deliver an email to the caller's mail account that will give you the information about full address resolution. The command-line output is typically just:

Mail Delivery Status Report will be mailed to <yourusername>.

postalias -q will show you what the alias file has in it, as the previous responder said, but this may or may not be what actually happens; sendmail -bv is more complete.

Josip Rodin
  • 1,695
  • 13
  • 18
malcolmpdx
  • 2,300
  • 1
  • 16
  • 12
  • 1
    I'm wondering why it's not more convenient for the program to also print the information we want on standard error. – Metamorphic Dec 29 '21 at 09:09
13

How about postalias:

 postalias -q tim@domain.com /path/to/your/valias_file
EdwardTeach
  • 632
  • 9
  • 20
  • 3
    Note that you can have multiple alias files, defined in the postfix config file. For instance, we have a file that is generated by our ERP and a manual file of "special" addresses. The command does appear to take multiple files as arguments, but it finds the first instance of what you're searching for and stops. There are some odd cases where an alias shows up in both files. So the postalias command would need to be called once for each of those files, to be sure that you got everything. – Phil Erb Jan 23 '12 at 18:12