Skip to content

Instantly share code, notes, and snippets.

@sumitdhameja
Created February 27, 2016 17:53
Show Gist options
  • Save sumitdhameja/fb6ac1ba5f07a56d8ba0 to your computer and use it in GitHub Desktop.
Save sumitdhameja/fb6ac1ba5f07a56d8ba0 to your computer and use it in GitHub Desktop.
Setting up Heirloom MailX to send emails from linux(Debian/ ubuntu) system:
mkdir MailX
cd MailX
#Download file
wget http://ftp.debian.org/debian/pool/main/h/heirloom-mailx/heirloom-mailx_12.5.orig.tar.gz
#Download patch
wget http://www.linuxfromscratch.org/patches/blfs/svn/heirloom-mailx-12.5-fixes-1.patch
#unZip
tar -xvzf heirloom-mailx_12.5.orig.tar.gz
#Remove after unzipping
rm -rf heirloom-mailx_12.5.orig.tar.gz
#Run following commands
patch -Np1 -i ../heirloom-mailx-12.5-fixes-1.patch &&
make SENDMAIL=/usr/sbin/sendmail -j1
#as a sudo user
make PREFIX=/usr UCBINSTALL=/usr/bin/install install &&
ln -v -sf mailx /usr/bin/mail &&
ln -v -sf mailx /usr/bin/nail &&
install -v -m755 -d /usr/share/doc/heirloom-mailx-12.5 &&
install -v -m644 README /usr/share/doc/heirloom-mailx-12.5
#Append config file with BC smtp
cat >> /etc/nail.rc <<EOF
# set smtp=smtp://smtp.server.tld:port_number
set smtp=smtp://smtp.emailsrvr.com
# tell mailx that it needs to authorise
set smtp-auth=login
# set the user for SMTP
set smtp-auth-user=bcsrvr@bluecava.com
# set the password for authorisation
set smtp-auth-password=RedSky123
EOF
# Test MailX by sending a mail
echo "hello world" | mail -s "a subject" sumeet@qualia-media.com
#!/bin/bash
while true
do
[ $(free -m| grep Mem | awk '{ print int($3/$2*100) }') -gt "85" ] && echo "Memory used is more than 85% - GraphDB - SandBox " | mail -s "Memory used more than 85%" devops@bluecava.com || echo "Memory used less than 85%"
sleep 600
done
#!/bin/bash
while true
do
if lsof -Pi :3000 -sTCP:LISTEN -t >/dev/null ; then
echo "Aerospike Running"
else
echo "Aerospike PORT DOWN!!!: 3000 GraphDB" | mail -s "Aerospike PORT DOWN!!!: 3000 GraphDB"
fi
sleep 120
done
@ndhambi
Copy link

ndhambi commented May 10, 2019

Hi,
I have just installed mailx on Ubuntu 16.04 , in which directory can i find the configuration file to set the SMTP server and password?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment