Skip to main content

List all Mail Forwarders

Comments

11 comments

  • cPanelLauren
    Hello @30feb What would be best to run to list forwarders would be the UAPI Email::list_forwarders which will provide a list of all forwarders for a domain. Documentation on this can be found here: UAPI Functions - Email::list_forwarders - Developer Documentation - cPanel Documentation The command line example is as follows: uapi --user=username Email list_forwarders domain=example.com
    Running cat /etc/valiases/* > forwarders.txt
    Should work - it worked for me locally. What happened when you did this?
    0
  • 30feb
    Hello, This is working fine - uapi --user=username Email list_forwarders domain=example.com But as i stated earlier i need a command to list all mail forwarders for entire domains on a VPS. Thanks
    0
  • cPanelLauren
    Hello @30feb As I stated in my previous response: Running cat /etc/valiases/* > forwarders.txt
    Should work - it worked for me locally. What happened when you did this?
    0
  • rpvw
    Create a .sh file (eg forwarders.sh) with the following content #!/bin/bash /bin/ls -1 /var/cpanel/users | while read USER; do /bin/echo "Now processing ${USER} ..." uapi --user=${USER} Email list_forwarders done
    and make it executable. Run file in a terminal, and it should output to terminal all the forwarders.
    0
  • cPanelLauren
    Create a .sh file (eg forwarders.sh) with the following content #!/bin/bash /bin/ls -1 /var/cpanel/users | while read USER; do /bin/echo "Now processing ${USER} ..." uapi --user=${USER} Email list_forwarders done
    and make it executable. Run file in a terminal, and it should output to terminal all the forwarders.

    That will actually hit a bump when it hits /var/cpanel/users/system what they were running before works though. You'd need to exclude the system user if you wanted to use the script: #!/bin/bash /bin/ls -1 /var/cpanel/users|grep -v system |while read USER;do /bin/echo "Now processing ${USER} ..." uapi --user=${USER} Email list_forwarders done
    0
  • rpvw
    Thanks @cPanelLauren I hadn't run that script for ages - good catch.
    0
  • cPanelLauren
    Thanks @cPanelLauren I hadn't run that script for ages - good catch.

    Thanks for posting it :D
    0
  • 30feb
    Hello @30feb As I stated in my previous response: Running cat /etc/valiases/* > forwarders.txt
    Should work - it worked for me locally. What happened when you did this?

    Hello, There is no output using this command. cat /etc/valiases/* > forwarders.txt It simply comes to command lines and nothing shows. Manav
    0
  • cPanelLauren
    Hi @30feb There wouldn't be output, because you're sending the data to forwarders.txt. Did you open the file to verify if the data was present? Thanks!
    0
  • Nermin
    Is there a possibility to send output from terminal to email from this script?
    0
  • cPRex Jurassic Moderator
    @Nermin - there are several different ways to send an email message from a terminal session. I'd recommend doing a web search for that as that wouldn't be directly related to any cPanel tools, but you might want to look into sendmail as that is configured with every cPanel server.
    0

Please sign in to leave a comment.