Skip to content

Instantly share code, notes, and snippets.

@faizalmansor
Last active June 24, 2019 11:20
Show Gist options
  • Save faizalmansor/9436bb5de206e25057bf6110912109c5 to your computer and use it in GitHub Desktop.
Save faizalmansor/9436bb5de206e25057bf6110912109c5 to your computer and use it in GitHub Desktop.
Script to automate installation & configuration of mailx
#!/bin/bash
# Script : ost-setup-mailx.sh
# Author : Osh <faizal@myopensoft.net>
# Title : Osh Automated Mailx Installer
# Description: Script to automate installation & configuration of mailx
# Target OS : Centos 7
echo "Start Osh Automated Mailx Installer..."
yum -y update
yum install -y mailx
cat <<EOT >> /etc/mail.rc
set smtp-use-starttls
set smtp-auth=login
set smtp=smtp://smtp.gmail.com:587
set from="YOUR_GMAIL@gmail.com(YOUR_PROJECT_NAME)"
set smtp-auth-user=YOUR_GMAIL@gmail.com
set smtp-auth-password=YOUR_GMAIL_PASSWORD
set ssl-verify=ignore
set nss-config-dir=~/certs
EOT
cd ~
mkdir certs
certutil -N -d certs
wget https://www.geotrust.com/resources/root_certificates/certificates/GeoTrust_Global_CA.cer
mv GeoTrust_Global_CA.cer certs/
echo -n | openssl s_client -connect smtp.gmail.com:465 -CAfile certs/GeoTrust_Global_CA.cer | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > GMAILCERT
certutil -A -n "Google Internet Authority" -t "C,," -d certs -i GMAILCERT
echo "Complete!"
@faizalmansor
Copy link
Author

Change YOUR_GMAIL, YOUR_GMAIL_PASSWORD, YOUR_PROJECT_NAME to your actual settings

Then run chmod +x ost-setup-mailx.sh before running the script for the first time.

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