Introduction
In a cPanel environment, there are no native/supported ways to send bulk emails locally , so you will need to create a script or a one-liner command to send emails to all the email accounts on the server.
Here is one such one-liner for demonstration:
- First you need to create a text file that contains the body and the main content of the email message that you wish to send
- Then you can run the below command to send the content of that file to all the locally hosted email accounts on the server:
Procedure
for i in $(awk '{print $2}' /etc/trueuserdomains); do uapi --user=$i Email list_pops 2> /dev/null | egrep "\s+email:" ; done | awk -F":" '{print $2}' | while read email; do mail -s "EMAIL SUBJECT" $email < /PATH/TO/FILE ;done
Note: In the command above you need to change the "EMAIL SUBJECT
" section with the subject you wish to choose for your email and also replace the "/PATH/TO/FILE
" section with the path to the file that you created above (The file that contains the body of the email)
Please bear in mind that this is only an example provided as a courtesy, so it's not guaranteed to work and we will not be able to modify or troubleshoot this for you. Nevertheless, you should be able to use the command demonstrated here as an example to create other commands/scripts that would better suit your needs.