Register
It is currently Fri Oct 24, 2014 10:13 pm

mailit function


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Fri Sep 03, 2010 8:05 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Here is a generic mail function I use with cron jobs or scripts that need to email information.
TIP: the context-type can be switched to sent html instead of plain text as well ;)

Code:
mailit ()
{
cat <<EOF | /usr/sbin/sendmail -f noreply -t
to:${sendto}
from:${from}
reply-to:${replyto}
subject: ${subject}
content-type: text/plain
${emailthis}
EOF
}


To use, set the variables first, then call the function ;) IE:
Quote:
sento="someone@someemail.com"
from="sentfrom@someemail.com"
replyto="sentfrom@someemail.com"
subject="This is the email subject"
emailthis=`cat <<EOF
This is is the text
that is sent
in the body of the email.

Thanks,
Crouse
EOF`

mailit


That's just one way of calling it. You could use read, could use it as a one line command ... possibilities are endless ;)

Hope someone else finds it useful.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP