[How To] Install Sendmail on Amazon EC2 BitNami stack server

The Amazon EC2  BitNami stack servers are used for hosting e-commerce/web applications. BitNami stacks are ready to use virtual machines. Being an e-commerce/Web application, it will require functionality to send email from the server. One may receive below error in the Apache error log if Sendmail service is not present in the server.

/usr/bin/sendmail: not found

Solution

1) Install Sendmail service

For Ubuntu:

sudo apt-get install sendmail

or

For Centos/RedHat:

install sendmail

2) Verify Sendmail installation

whereis sendmail
sendmail: /usr/sbin/sendmail /usr/lib/sendmail /usr/share/sendmail /usr/share/man/man8/sendmail.8.gz

3) Update Sendmail path in php.ini

sudo vi /opt/bitnami/php/etc/php.ini
sendmail_path = /usr/sbin/sendmail -t -i -f root@your_server_hostname

4) Restart Apache service

sudo /opt/bitnami/ctlscript.sh restart apache2

5) Test by sending mail using mail command

echo "This is a test mail. Please do not reply" | mail -s Test Email username@domain.com

If the mail arrives in your mail inbox then the mail service is working fine.

Note: It is advised to use smtp() function instead of mail() function for sending emails on the Amazon servers. This is because Amazon restricts the number of emails sent through mail() / Sendmail.

The smtp script can be found here.

That's all!

Share on FacebookShare on Google+Tweet about this on TwitterShare on StumbleUponShare on LinkedInShare on TumblrDigg thisPin on PinterestShare on RedditEmail this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing the knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CAPTCHA Image

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>