Skip to content

Instantly share code, notes, and snippets.

@dobrivoje
Last active April 11, 2017 10:56
Show Gist options
  • Save dobrivoje/d431b8956c8803eaf27003f96626281e to your computer and use it in GitHub Desktop.
Save dobrivoje/d431b8956c8803eaf27003f96626281e to your computer and use it in GitHub Desktop.
### We're installing dependencies (certutils commdand)
### based on the fantastic explanation covered here : https://coderwall.com/p/ez1x2w/send-mail-like-a-boss
apt-get install libnss3-tools
mkdir certs
### optional
chown -R root:tomcat certs/
chmod 770 -R certs/
certutil -N -d certs/
### assuming we are in /root directory, and want to add following files in the /root/ssl/certs folder
### we're issuing following command :
echo -n | openssl s_client -connect smtp.gmail.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/ssl/certs/gmail.crt
certutil -A -n "Google Internet Authority" -t "C,," -d ~/ssl/certs -i ~/ssl/certs/gmail.crt
### We're testing with the following command :
echo -e "Email content..." | mailx -v -s "Email subject" -S smtp-use-starttls \
-S ssl-verify=ignore -S smtp-auth=login -S smtp=smtp://smtp.gmail.com:587 \
-S from="email_we're_sending_from@gmail.com (e.g. your name)" -S smtp-auth-user=email_we're_sending_to@gmail.com \
-S smtp-auth-password=<email_pasword> -S ssl-verify=ignore -S nss-config-dir=~/ssl/certs \
email_we're_sending_to@gmail.com
### Above we may put our name in brackets for more decriptive email :
### -S from="email_we're_sending_from@gmail.com (e.g. your name)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment