Tuesday, October 22, 2013

Sending email through in linux

Example 1:
echo "This is the body of email" | mail -s "This is the Subject" cybertech@cybertech.com
 
Example 2:
in a bash script file:-
 

#!/bin/bash
# script to send simple email
# email subject
SUBJECT="This is Subject"
# Email To ?
EMAIL="cybertech@cybertech.com"
# Email text/message
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "This is an email message test"> $EMAILMESSAGE
echo "This is email text" >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

No comments: