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-line command to send emails to all the email accounts on the server. This article provides an example of a one-line command.
Please note that the example is provided as a courtesy and is not guaranteed to work for you. cPanel support cannot modify or troubleshoot this for you.
Procedure
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Create a new text file.
touch /PATH/TO/FILE"
Please note that "/PATH/TO/FILE" must be replaced with the path to the file you will create. - Open the file in your preferred text editor.
- Enter the contents of the email message that you wish to send.
- Save the changes and exit the text editor.
- Run the following command to send the emails.
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
Please note that "EMAIL SUBJECT" and "/PATH/TO/FILE" must be replaced with the subject you wish to use for the email and the path to the file created above.
Comments
0 comments
Article is closed for comments.