Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
executable file 71 lines (59 sloc) 1.87 KB
# Setup nullmailer on Ubuntu using your Gmail account as SMTP
# - you get a working sendmail command without requiring to setup complex SMTP
# stuff. Mostly useful with cron scripts.
# Orignal script based on
# and
# Abort script if any command fails
set -e
# Create a gmail SSL wrapper script
if [ -z "$GMAIL_USER" ] || [ -z "$GMAIL_PASSWORD"|| [ -z "$TEST_ADDRESS" ] ; then
echo "Setup sendmail via gmail proxy on your Ubuntu box"
echo "Usage:"
echo " GMAIL_PASSWORD=12312312 sh"
exit 1
# install required software
sudo apt-get install -y openssl xinetd nullmailer
sudo tee /usr/bin/gmail-smtp <<EOF >/dev/null
/usr/bin/openssl s_client -connect -quiet 2>/dev/null
sudo chmod +x /usr/bin/gmail-smtp
# Create xinetd.d entry which wraps SMTP traffic to port 10025 go
# go to gmail
sudo tee /etc/xinetd.d/gmail-smtp <<EOF >/dev/null
# default: on
# description: Gmail SMTP wrapper for clients without SSL support
# Thanks to for this install guide
service gmail-smtp
disable = no
bind = localhost
port = 10025
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/gmail-smtp
type = unlisted
sudo /etc/init.d/xinetd reload
# Set nullmail to use xinetd
sudo tee /etc/nullmailer/remotes <<EOF >/dev/null smtp --port=10025 --user=$GMAIL_USER --pass=$GMAIL_PASSWORD
sudo /etc/init.d/nullmailer reload
# send test email
echo "This is a test message from ${USER}@${HOSTNAME} at $(date)" | sendmail $TEST_ADDRESS
echo "Test mail send to $TEST_ADDRESS"