Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active November 12, 2022 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilangvperdana/99bd5db021647158370a703f3086831d to your computer and use it in GitHub Desktop.
Save gilangvperdana/99bd5db021647158370a703f3086831d to your computer and use it in GitHub Desktop.
SMTP Client on our Ubuntu Server

Goals

  • Can use SMTP platform on our ubuntu server

Install SSMTP

sudo apt-get install ssmtp

Configure Account

nano /etc/ssmtp/ssmtp.conf

---
mailhub=mail.gilang.org:587
useSTARTTLS=NO
AuthUser=account@gilang.org
AuthPass=YOURMAILPASSWORD

Configure Email Client

nano email.sh
---
#!/bin/sh  
SUBJECT="Test Subject"
TO="client@gmail.com"
MESSAGE="Hey There! This is a test mail"

echo $MESSAGE | sudo ssmtp -vvv $TO
--
chmod +x email.sh
nano sendemail.sh
--
#!/bin/bash
for i in {1..5}
do
   /root/email.php
done
chmod +x sendemail.sh
./sendemail.sh

Use mailutils

You can use mailutils to send with command mail

apt install -y mailutils
echo $MESSAGES | mail -s "$SUBJECT" $EMAIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment