Sunday, October 24, 2010

How to send mail using bash script?

You can use following script to send mail(Pls change the e-mail address and its content)
--------
#!/bin/bash
# script to send simple email
# email subject
SUBJECT="SET-EMAIL-SUBJECT"
# Email To ?
EMAIL="admin@somewhere.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
-------

try :)

2 comments:

  1. Hello Kamal,

    Your all blogs are VERY VERY GOOD AND NICE. Can you give me your phone number, I want to talk with you. This My Email Id vanmalirahul@gmail.com, send me your phone no on above ID.

    I AM VERY IMPRESS ON YOUR ALL BLOGS.

    THANK YOU.
    RAHUL VANMALI(RV)

    ReplyDelete
  2. Hi,

    sorry, but how can I tell mail to use a local smtp gateway (postfix:25)?
    I'm using RHEL 5.6.
    alternatives --display mta
    gives me back:
    sendmail.postfix
    as current.

    Thanks

    ReplyDelete