Setup email on your Linux server

I use ubuntu for my webserver. When I want the system to send me alerts or notifications, it doesn’t know how. It will create a system generated email but it doesn’t go anywhere. So why not tell it to use gmail to send emails.

# apt-get install mailx

# apt-get install exim4 exim4-config

Choose “mail sent by SMARTHOST; Received via SMTP or fetchmail”

Type System Mail Name “xxx.xxx.com” eg webz.mot.is-a-geek.com

Type IP address to listen on for incoming SMTP: 127.0.0.1

Leave Other Destinations BLANK

Leave Machines to relay BLANK

Type Machine Handling outgoing mail (smarthost) smtp.gmail.com:587

Choose NO, don’t hid local mail

Choose NO, don’t keep number of DNS queries minimal

Choose YES, split configuration into smaller files

Now edit /etc/exim4/passwd.client

nano /etc/exim4/passwd.client

Add the lines

gmail-smtp.1.google.com:yourAccountName@gmail.com:Y0uRpAssW

*.google.com:yourAccountName@gmail.com:Y0uRpAssW

smtp.gmail.com:yourAccountName@gmail.com:Y0uRpAssW

Then make sure root owns the file

chown root /etc/exim4/passwd.client

Now test the system

mail you@yourself.com

enter a subject

enter some body text and press Ctrl+d when finished. Check your mail.

Leave a Reply

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