Skip to main content

Posts

Showing posts from November, 2017

Automated linux shell script to setup Postfix on RHEL7 with Gmail

In my previous article on "How to setup unauthenticated mail server configuration using mail forwarding with authentication", I've tried to collate all the steps required to setup Postfix server on RHEL7. Here, I simply automate it.
Why do it manually, when you could do the same with automation for next 5 years.
-- Random Thoughts #!/bin/sh ###################################################### # This script will enable the linux postfix setup. # Ensure that mail, postfix and openssl are installed. # @author cubicrace.com ###################################################### SMTP_HOST=$1 SMTP_PORT=$2 SMTP_USERNAME=$3 SMTP_PASSWORD=$4 POSTFIX_DIR=/etc/postfix MAIN_CF=${POSTFIX_DIR}/main.cf HOSTNAME=`hostname` ERROR(){ local line=$3 [ ! -z $3 ] && line=`expr $line - 1` || line="" echo "$1, RC=$2, ERROR on line: $line" exit $2 } INFO(){ echo "$1" } addProperty(){ echo "${1} = ${2}" >> ${3} if [ $…

How to setup unauthenticated mail server configuration using mail forwarding with authentication

We want to send mails which are authenticated by a mail server, but the application can only send mails to a unauthenticated mail server. We achieve this end result of authenticated mails, by using postfix (a mail relay/forwarding tool ).

What is Postfix? Its a mail server program written by "Wietse Zweitze Venema" that started life at IBM Research as an alternative to the most popular linux "Sendmail" tool. Now he works at Google,  and continues to support Postfix.

Postfix attempts to be fast, easy to setup, and secure. After using postfix you may feel that it's just a sendmail tool, but from inside its completely different. Most Linux OS would have postfix installed by default, if not you can install it using yum or apt-get based on your OS. Before setting up postfix make sure you also have the mail tool installed. Lets try to go through the flow we want to achieve.



Configuration Steps (RedHat):
1. Install the tools
yum update && yum install postfix ma…