Enabling PHP mail() Function in Centos 6.x

posted in: Computers, Technical | 0

It is needed to have the capability of sending email directly from localhost of one of web servers owned by the university. The purposes are that several CMS (WordPress, etc) and LMS (Moodle, etc) applications that hosted on the server could be able to send email for various purposes such as sending password reset link, student assignments submission notifications and etc.
The server is running Centos 6.x and here are the instructions used to activate the feature.

First, install sendmail with $ sudo yum install sendmail sendmail-cf.

Then, configure sendmail by editing the file /etc/mail/sendmail.mc (do not edit the sendmail.cf file directly – the configuration contents of the file will  automatically generated after correct configuration in sendmail.mc has been made).

  • Configure DAEMON_OPTIONS to only allow sending from localhost/smtp: check if the line DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl exists and it is not commented within the configuration file
  • Set the LOCAL_DOMAIN option to the hostname of the configured server/host: LOCAL_DOMAIN(`hotumese.unpatti.ac.id')dnl
  • check and alter the LOCAL_DOMAIN line that suits the hostname of the server.
  • Next, update sendmail’s configuration by using the command: $ sudo make -C /etc/mail, and then restart sendmail with the command: $ sudo service sendmail restart.

After proceed with the configurations explained, the capability for sending mail directly from localhost that available within CMS (WordPress, Joomla) and LMS (Moodle, etc) is working.

Reference: http://www.jeffgeerling.com/blogs/jeff-geerling/configure-sendmail-centos