Sendmail Example Usage for Bash

Useful snippet I wrote up after searching the internet for details on syntax for sendmail in Linux.

PRETTY_HOSTNAME=$(hostnamectl --pretty)
ADMIN_USERNAME='username'
ADMIN_PASSWORD='password'

sendmail -F "noreply@website.com" -it <<END_MESSAGE
Content-Type: text/html
MIME-Version: 1.0
To: person@email.com
Subject: [INFO] Connection Details
Hostname: $PRETTY_HOSTNAME <br />
If your program is down, do the following.
<br />
1. Open Putty <br />
2. Establish Connection to $PRETTY_HOSTNAME <br />
2a. Username: $ADMIN_USERNAME <br />
2b. Password: $ADMIN_PASSWORD <br />
3a. Check for the status of your program. <br />
If there are any questions or concerns please reach out to your server admin.
<br />
Thanks, <br />
Automated System 
END_MESSAGE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s