How to send email in a shell script?

How to send email in a shell script?

Post by ShadowMAC Administrat » Thu, 17 Dec 1998 04:00:00



SunSparc under the Solaris OS.

We are a filesite and we are in the process of finishing a script which
will finish the processing of newly uploaded archives into our site.

But we are stuck on one aspect of this script, we want to notify the
author's of the archives uploaded to our site that they have a copy of
their archive on our site (as a simple courtesy, so they can include their
archive's URL on our site in anything they may want to, or whatever), and
to allow the publisher or author to proof the descriptives relating to
their archives.

We also need to include in the emailing a header text and a footer text
from a pair of textfiles.

We are stuck on how to email those authors from our shell script with the
info, we've looked at mail and mailx, so I am posting to ask how we can
accomplish this last bit in our shell script...  below I am including an
example of what we need and want to send.

Basic Email Example Start
-------------------------

      T: ${author}
Subject: ${filename} uploaded to our site.
Content:

[HEADER TEXTFILE START]
Hello,
We are notifying you that a copy of one of your archives
has been processed into our filebase, we include a URL
below by which if you wish to you may examine your
archive's filebase descriptives, if desired you may let
us know if you need any of the descriptives modified and
modified in what way(s).
[HEADER TEXTFILE END]

        Filepathing: ${filepathing}
            Version: ${version}
    Date of release: ${date_of_release}
  Terse description: ${terse_description}
Verbose description: ${verbose_description}
    FTP downloading: ${ftp_downloadable_url}
   HTTP downloading: ${http_downloadable_url}

If this is an older version then we would like to request that you
think about uploading a copy of your newer version to us at

http://our.system.org/upload.html

or

ftp://our.system.org/uploads

and we will process it into our filebase as soon as possible.

Thank you for your archive and the your attention.

Filebase Admin.
His or her name

[FOOTER TEXTFILE START]
         Our system info is
Blah blah blah.....etc...
[FOOTER TEXTFILE END]
-----------------------
Basic Email Example End

Not sure if we need the above to use mail, or mailx, or even just send it
direct to sendmail.

Ideas?  Suggestions?

Please copy your replies to email as well as in this group.

Thanks!

 
 
 

How to send email in a shell script?

Post by Henry Thompso » Thu, 17 Dec 1998 04:00:00



> SunSparc under the Solaris OS.

> We are a filesite and we are in the process of finishing a script which
> will finish the processing of newly uploaded archives into our site.

> But we are stuck on one aspect of this script, we want to notify the
> author's of the archives uploaded to our site that they have a copy of
> their archive on our site (as a simple courtesy, so they can include their
> archive's URL on our site in anything they may want to, or whatever), and
> to allow the publisher or author to proof the descriptives relating to
> their archives.

> We also need to include in the emailing a header text and a footer text
> from a pair of textfiles.

> We are stuck on how to email those authors from our shell script with the
> info, we've looked at mail and mailx, so I am posting to ask how we can
> accomplish this last bit in our shell script...  below I am including an
> example of what we need and want to send.

We do this so much that we wrote a script that can be called from any
where on our site.  We put the TO email address in a text file so that
it is easier to update than change the code.  All you need to do is to
call this code with a email address file and a file that you want
emailed(which you can build before hand or on the fly).  and it is
mailed.

Here is the jist of it
---------------------------------------------

#!/bin/sh
#
#put the param in vars
EMAILFN=$1
FILE=$2

Check to see if the files in the params exist
if [ ! -f ${FILE} -o  ! -f ${EMAILFN} ]
then
   echo "ERROR"
   exit 1
fi

#create the email message from
#the message body and the email address
/usr/ucb/echo -n "To: " > /tmp/email.tmp.$$
cat ${EMAILFN}         >> /tmp/email.tmp.$$

cat ${FILE}            >> /tmp/email.tmp.$$

EMAIL=`cat ${EMAILFN}`

#use sendmail to mail the email
/usr/lib/sendmail \
${EMAIL} \
< /tmp/email.tmp.$$

/bin/rm /tmp/email.tmp.$$

exit 0

#-----------------------------------------------

 
 
 

How to send email in a shell script?

Post by Vadim Kuevd » Fri, 18 Dec 1998 04:00:00


(echo ...
 cat ...
 everything ...) | /usr/ucb/Mail -s "SUBJECT" RECIPIENT


> SunSparc under the Solaris OS.

> We are a filesite and we are in the process of finishing a script which
> will finish the processing of newly uploaded archives into our site.

> But we are stuck on one aspect of this script, we want to notify the
> author's of the archives uploaded to our site that they have a copy of
> their archive on our site (as a simple courtesy, so they can include their
> archive's URL on our site in anything they may want to, or whatever), and
> to allow the publisher or author to proof the descriptives relating to
> their archives.

> We also need to include in the emailing a header text and a footer text
> from a pair of textfiles.

> We are stuck on how to email those authors from our shell script with the
> info, we've looked at mail and mailx, so I am posting to ask how we can
> accomplish this last bit in our shell script...  below I am including an
> example of what we need and want to send.

> Basic Email Example Start
> -------------------------

>       T: ${author}
> Subject: ${filename} uploaded to our site.
> Content:

> [HEADER TEXTFILE START]
> Hello,
> We are notifying you that a copy of one of your archives
> has been processed into our filebase, we include a URL
> below by which if you wish to you may examine your
> archive's filebase descriptives, if desired you may let
> us know if you need any of the descriptives modified and
> modified in what way(s).
> [HEADER TEXTFILE END]

>         Filepathing: ${filepathing}
>             Version: ${version}
>     Date of release: ${date_of_release}
>   Terse description: ${terse_description}
> Verbose description: ${verbose_description}
>     FTP downloading: ${ftp_downloadable_url}
>    HTTP downloading: ${http_downloadable_url}

> If this is an older version then we would like to request that you
> think about uploading a copy of your newer version to us at

> http://our.system.org/upload.html

> or

> ftp://our.system.org/uploads

> and we will process it into our filebase as soon as possible.

> Thank you for your archive and the your attention.

> Filebase Admin.
> His or her name

> [FOOTER TEXTFILE START]
>          Our system info is
> Blah blah blah.....etc...
> [FOOTER TEXTFILE END]
> -----------------------
> Basic Email Example End

> Not sure if we need the above to use mail, or mailx, or even just send it
> direct to sendmail.

> Ideas?  Suggestions?

> Please copy your replies to email as well as in this group.

> Thanks!

--
Vadim V. Kuevda              | Phone: 81 (03) 5424-4314
Morgan Stanley Japan Limited | Fax:   81 (03) 5424-4399
=======================================================

 
 
 

How to send email in a shell script?

Post by Hoa Thanh » Fri, 18 Dec 1998 04:00:00


generate the file you want to send and redirect it into mail will do


: SunSparc under the Solaris OS.
:
: We are a filesite and we are in the process of finishing a script which
: will finish the processing of newly uploaded archives into our site.
:
: But we are stuck on one aspect of this script, we want to notify the
: author's of the archives uploaded to our site that they have a copy of
: their archive on our site (as a simple courtesy, so they can include their
: archive's URL on our site in anything they may want to, or whatever), and
: to allow the publisher or author to proof the descriptives relating to
: their archives.
:
: We also need to include in the emailing a header text and a footer text
: from a pair of textfiles.
:
: We are stuck on how to email those authors from our shell script with the
: info, we've looked at mail and mailx, so I am posting to ask how we can
: accomplish this last bit in our shell script...  below I am including an
: example of what we need and want to send.
:
: Basic Email Example Start
: -------------------------

:       T: ${author}
: Subject: ${filename} uploaded to our site.
: Content:
:
: [HEADER TEXTFILE START]
: Hello,
: We are notifying you that a copy of one of your archives
: has been processed into our filebase, we include a URL
: below by which if you wish to you may examine your
: archive's filebase descriptives, if desired you may let
: us know if you need any of the descriptives modified and
: modified in what way(s).
: [HEADER TEXTFILE END]
:
:         Filepathing: ${filepathing}
:             Version: ${version}
:     Date of release: ${date_of_release}
:   Terse description: ${terse_description}
: Verbose description: ${verbose_description}
:     FTP downloading: ${ftp_downloadable_url}
:    HTTP downloading: ${http_downloadable_url}
:
: If this is an older version then we would like to request that you
: think about uploading a copy of your newer version to us at
:
: http://our.system.org/upload.html
:
: or
:
: ftp://our.system.org/uploads
:
: and we will process it into our filebase as soon as possible.
:
:
: Thank you for your archive and the your attention.
:
:
: Filebase Admin.
: His or her name
:
:
: [FOOTER TEXTFILE START]
:          Our system info is
: Blah blah blah.....etc...
: [FOOTER TEXTFILE END]
: -----------------------
: Basic Email Example End
:
:
: Not sure if we need the above to use mail, or mailx, or even just send it
: direct to sendmail.
:
: Ideas?  Suggestions?
:
: Please copy your replies to email as well as in this group.
:
: Thanks!

 
 
 

How to send email in a shell script?

Post by Trond Norby » Sat, 19 Dec 1998 04:00:00



> generate the file you want to send and redirect it into mail will do



Why /usr/ucb/mail ???
         ^^^

In my opinion /usr/ucb should be removed.

Trond Norbye
--
Software Engineer


Professor Brochs g 6
N-7030 Trondheim                                  phone: +47 73 54 02 36
NORWAY

 
 
 

How to send email in a shell script?

Post by Steve Bellen » Sat, 19 Dec 1998 04:00:00





>> generate the file you want to send and redirect it into mail will do


>Why /usr/ucb/mail ???
>         ^^^

>In my opinion /usr/ucb should be removed.

/usr/ucb/mail is a soft link to /bin/mailx
--

 
 
 

How to send email in a shell script?

Post by Trond Norby » Sat, 19 Dec 1998 04:00:00



> >Why /usr/ucb/mail ???
> >         ^^^

> >In my opinion /usr/ucb should be removed.

> /usr/ucb/mail is a soft link to /bin/mailx

And still I ask: Why /usr/ucb/mail.....

(why not /usr/bin/mailx)

--
Software Engineer


Professor Brochs g 6
N-7030 Trondheim                                  phone: +47 73 54 02 36
NORWAY

 
 
 

How to send email in a shell script?

Post by Hoa Thanh » Thu, 24 Dec 1998 04:00:00


/usr/ucb/mail, /bin/mailx, /usr/bin/mailx are the same thing (mailx).
ls -l /usr/ucb/mail
ls -l / |grep bin
will show you.

It is just a way to make your script runs on most flavor of UNIXes.

:
: > >Why /usr/ucb/mail ???
: > >         ^^^
: > >
: > >In my opinion /usr/ucb should be removed.
: >
: > /usr/ucb/mail is a soft link to /bin/mailx
:
: And still I ask: Why /usr/ucb/mail.....
:
: (why not /usr/bin/mailx)
:
:
: --
: Software Engineer
:

: Professor Brochs g 6
: N-7030 Trondheim                                  phone: +47 73 54 02 36
: NORWAY

 
 
 

1. Sending email from a shell script using sendmail or mail

I want to send a simple email from a unix
shell script.  The message must include
a subject.  I have done this...


The above does work, I get a body,
but I dont get a subject line. It's blank.

I have also done this..


This does put 'this is a subject' on the Subject: line
but no body.  I discovered this out by total luck.  
I figure I must be on to something here.
I would like to have a subject and a body.  
Can any refer me to a tutorial on the web about formating text files
to be piped to sendmail or mail for that matter.
Does anyone have other simpler ideas?
I have read the man pages on sendmail and rfc 821 but they
dont seem help on this area.

Thanks..

2. Linux printer and Windows 95

3. How to attach file to EMAIL MESSAGE within shell script(Korn shell)

4. Crashe - REBOOT Message

5. extract email from text file and send an email to the email address

6. firewall on a virtual web server with multiple IPs

7. Incomplete output from crontab email: running shell scripts from a perl script

8. socket programming UDP

9. Send a HTMl-email from the shell

10. sending email from shell WITHOUT sendmail

11. Sending binary file via email from shell

12. Need shell help sending emails w\ attachments

13. how to send attachment via email in script?