Pol Hallen
Pol Hallen

Reputation: 1872

a better way to create an email template with bash

Using bash to create an email template:

#!/bin/bash
VAR1="today is "
VAR2="a good day"

echo "Good Morning" >> /tmp/email_template
echo $VAR1$VAR2 >> /tmp/email_template
echo "Best regards" >> /tmp/email_template
cat /tmp/email_template|mutt -s "Hello!" [email protected]

is there something more clean to create an email template?

Upvotes: 0

Views: 553

Answers (2)

LeadingEdger
LeadingEdger

Reputation: 724

This is how you would do it using the HERE doc approach:

#!/bin/bash
VAR1="today is "
VAR2="a good day"

mutt -s "Hello!" [email protected] <<EOF
Good Morning
$VAR1$VAR2
Best regards
EOF

Upvotes: 1

Matt Shin
Matt Shin

Reputation: 434

You can use a HERE doc as mentioned by a comment above or you can use a block like this:

#!/bin/bash
VAR1="today is "
VAR2="a good day"

{
echo "Good Morning"
echo "$VAR1$VAR2"
echo "Best regards"
} | mutt -s "Hello!" '[email protected]'

Upvotes: 1

Related Questions