Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active Nov 12, 2022
Embed
What would you like to do?
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