Background:
I need email functionality to send emails from the web server by querying data from MySQL database and email the result to appropriate recipient.
Workaround:
- Install sendmail.
-
sudo apt-get update
-
sudo apt-get install sendmail
-
- Install mailutils.
-
sudo apt-get install mailutils
-
- Configure the /etc/hosts file, provide your domain name in the following format
-
127.0.0.1 localhost yourhostname
-
- Configure the sendmail, provide Yes to all when prompt.
-
sudo sendmailconfig
-
- Find the sendmail path.
-
which sendmail
-
- Locate the php.ini file.
-
locate php.ini
-
- Open the php.ini file and provide the result of the “which sendmail” as entry for sendmail_path variable,if entry already exists uncomment it. For my case “which sendmail” output is /usr/sbin/sendmail.
-
sendmail_path = "env -i /usr/sbin/sendmail -t -i"
-
- Restart Apache server
-
sudo service apache2 restart
-
- Send a test email:
- Connect with telnet on port 25
-
telnet 127.0.0.1 25
-
- Type the following to see the server works
-
helo server
-
- Supply the Sender address
-
MAIL from: email@yourdomain.com
-
- Supply the Recipient address
-
RCPT to: your-email@xyz.com
-
- Provide the email contents and at the end type the dot(.) in anew line to send email.
-
Subject: Test email
- This is a test email from sendmail.
-
.
-
- Check to see the email arrived, if not found in inbox search it in junk folder.
- Connect with telnet on port 25