Posts tagged with: sendmail

Setup server to send email directly in Ubuntu without using SMTP gateway

There are a lot of usage for servers such as web hosting, filesharing, application hosting and so on. Most of these servers does no need to have a full fledged email service running in them. However, very often these servers still need to send out emails for example, in the form of alerts such as diskspace full and so on. There are basically 2 ways of doing this,

1) setup server or applications to send email using SMTP login to a proper email server

2) setup server to allow it send out email directly without going through SMTP

The proper way of doing this is using method 1. However it entails a lot of work and I personally prefer method 2. It is much easier to setup and does not rely on SMTP server to send out email. Here, I will show how to setup server to send out email using method 2 on Ubuntu using postfix MTA. It should work for most version of Ubuntu and Debian based system.

apt-get update

apt-get install postfix mailx

During postfix installation, you will be brought to postfix setup screen. If you don’t get that screen, manually type dpkg-reconfigure postfix.

General type of mail configuration: Internet

Just press enter for the rest of the options.

Once this is done, a basic config file will be generated for postfix. You don’t really need to config file. You can just empty it and restart postfix.

cat /dev/null > /etc/postfix/main.cf

/etc/init.d/postfix restart

Test sending out email:

echo testing | mail -s subjecttesting email@youremail.com

Done