Differences between revisions 19 and 20
Revision 19 as of 2023-10-30 06:34:25
Size: 1147
Editor: PhilWyett
Comment:
Revision 20 as of 2023-10-30 09:54:38
Size: 1188
Editor: PhilWyett
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
== Basic SSMTP setup == == Basic SSMTP setup for sending email from bash scripts etc. ==


Basic SSMTP setup for sending email from bash scripts etc.

This article is aimed at those who only require a basic/simple email sending setup for use in shell scripts etc.

Packages to be installed

Packages to be installed if not already.

  • ssmtp

sudo apt install ssmtp

Configure SSMTP

Configure machine you will be sending emails from by editing /etc/ssmtp/ssmtp.conf.

sudo nano /etc/ssmtp/ssmtp.conf

# The full hostname
hostname=ks-kenobi

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

# Kathenas
UseTLS=YES
root=SENDING_EMAIL_ADDRESS
mailhub=SENDING_EMAIL_ACCOUNT_SERVER_ADDRESS
AuthUser=SENDING_EMAIL_ACCOUNT_USERNAME
AuthPass=SENDING_EMAIL_ACCOUNT_PASSWORD

Bash script for testing

#!/bin/bash

sender="SENDING_EMAIL_ADDRESS"
recipient="RECIPIENT_EMAIL_ADDRESS"
subject="Test Email"
body="This is a test email sent using SSMTP."

echo -e "Subject:${subject}\n${body}" | ssmtp -f "${sender}" "${recipient}"