Applicable to:
- Plesk for Linux
Symptoms
- The server is set to Allow users and scripts to use Sendmail at Tools&Settings > Mail Server Settings
- The subscription created is based on a Service Plan with Mail service disabled
- Emails sent using the PHP mail() function are not delivered.
Cause
Plesk bug PPPM-12408. In the /var/log/maillog
the following error can be found:
CONFIG_TEXT: Rejecting message: system user is not allowed to send mail
Resolution
As a workaround:
Click on a section to expand
- Log in to Plesk
- Go to Domains > example.com > Mail tab > Mail settings
- Check the Activate mail service on this domain option and click Apply
- Uncheck Activate mail service on this domain option and click OK
- Connect to the server via SSH
- Execute the following command to enable and disable mail service for domain:
# plesk bin mail --create-service example.com && plesk bin mail --off example.com
- Connect to the server via SSH
- Create script phpmail.sh and start editing it:
# vi /root/phpmail.sh
- Add the following content to it and save changes:
CONFIG_TEXT: #!/bin/bash
echo "--------------" >> /tmp/event_handler.log
/bin/date >> /tmp/event_handler.log
/usr/bin/id >> /tmp/event_handler.log
PLAN_NAME=$(plesk bin site --info ${NEW_DOMAIN_NAME} | egrep Subscription\ Information -A5 | egrep service\ plan | cut -d'"' -f2)
MAIL_ACTIVE=$(plesk bin service_plan --info "$PLAN_NAME" | egrep Settings -A5 | egrep Mail\ | awk '{print $2}')
echo "${NEW_DOMAIN_NAME} -> $PLAN_NAME / Mail Service = $MAIL_ACTIVE" >> /tmp/event_handler.log
if [ "$MAIL_ACTIVE" == "false" ]; then
echo "ACTION => Create service + switch off" >> /tmp/event_handler.log
plesk bin mail --create-service ${NEW_DOMAIN_NAME}
plesk bin mail --off ${NEW_DOMAIN_NAME}
fi
echo "--------------" >> /tmp/event_handler.log - Make the script executable:
# chmod +x /root/phpmail.sh
- Log in to Plesk
- Go to Tools&Settings > Event Manager > Add event handler and add the event as follows:
- Click OK to save changes.
Comments
0 comments
Please sign in to leave a comment.