List all Mail Forwarders
Hello
Can anyone suggest the commands to list all mail forwarders in SSH Root. As these commands are not working.
cat /etc/valiases/* > forwarders
or
more /etc/valiases/* > forwarders
Thanks
-
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
Runningcat /etc/valiases/* > forwarders.txt
Should work - it worked for me locally. What happened when you did this?0 -
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 -
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 -
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 -
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 done0 -
Thanks @cPanelLauren I hadn't run that script for ages - good catch. 0 -
Thanks @cPanelLauren I hadn't run that script for ages - good catch.
Thanks for posting it :D0 -
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. Manav0 -
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 -
Is there a possibility to send output from terminal to email from this script? 0 -
@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.
Comments
11 comments