Email script : A complement to unraid_notify


Recommended Posts

Hi Everyone, I am a long time reader but this is my 1st post!

 

I made a small package to add email support using the bashmail script from unraid_notify package. Credits goes to brainbone for unraid_notify package.

 

It use the same config file as unraid_notify (/boot/config/unraid_notify.cfg). I made this to enable sending email from any scripts and/or crontab jobs without using unraid_notify.

You still have to install unraid_notify-2.20-noarch-unRAID.tgz package *BUT* you don't have to start it if you don't want to.

 

Syntax: mail [--subject 'subject'] [--rcpt '[email protected]']"

 

Samples Usage:

  cat filename.txt | mail

  echo 'this is a test' | mail

  echo 'this is a test' | mail --subject 'ATTENTION'

  echo 'this is a test' | mail --subject 'ATTENTION' --rcpt [email protected]

 

You can override the subject and the rcpt from the configuration file (unraid_notigy.cfg) with the optionals parameters.

 

Regards

Mike

 

 

Link to comment
  • 3 weeks later...

@mikep

 

I was just getting ready to write something like this to use bashmail, and you have already done it.

 

Thank you.

 

I did make one change, so that the recipient comes from "ErrorRcptTo" and not "RcptTo" since a lot of people leave the latter blank, as they only want e-mail in the event of errors.

Link to comment

I'm just curious. Why would you want (or need) to use this package instead of brainbone's script or is there a different purpose for this package?

 

I guess with this, you can send emails from any script that has an output?

 

What would be some practical applications of this?

 

Thanks

Chris

Link to comment

I'm just curious. Why would you want (or need) to use this package instead of brainbone's script or is there a different purpose for this package?

 

I guess with this, you can send emails from any script that has an output?

 

What would be some practical applications of this?

 

Thanks

Chris

Some of the add-on scripts can be configured to use mail to communicate their status.  the APC UPS daemon is one. (I used my own script that in turn uses netcat for the actual connection to the mail server, but this is equally capable.)
Link to comment

I'm just curious. Why would you want (or need) to use this package instead of brainbone's script or is there a different purpose for this package?

 

I guess with this, you can send emails from any script that has an output?

 

What would be some practical applications of this?

 

Thanks

Chris

 

I wrote that script to use with APC UPS daemon and also some custom cron jobs...

Regards

Mike

 

 

Link to comment

OK. I tried to play with this a bit to see what I could do.

 

For example, I wrote a little script to save a text file containing the SMART info from drive #1 then email this to me.

 

Here's the script:

 

smartctl  -a  -d  ata  /dev/sdc | todos >/boot/smart.txt

cat /boot/smart.txt | mail --subject 'SMART info Disk1' --rcpt [email protected]

 

When I look at the email I get, the formatting is messed up. It looks like it doesn't print the tabs, so all the columns in the report do not line up and it's hard to read. If I check the text file, it's OK. Is there a way to keep the formatting intact? I tried using todos and not using it but it made no difference.

 

I also tried using "show in fixed width font" in Gmail but that didn't help either.

 

Any suggestions?

 

Thanks

Chris

Link to comment

Might there be a way to add an SMS feature.  I can send an email to my phone with this script via SMS (i.e. [email protected]), and this works just fine.

 

The problem I'm trying to avoid is that the default message creates 2 SMS texts because there are so many lines included in the message (FRM, SUBJ, MSG, Server Name, Date, and the message.)

 

If there were an SMS option (switch) so that only the message (or subject) were actually sent, that would be great.  I'd use this feature to notify me of specific 'events' (such as rsync completed sucessfully).

Link to comment
  • 1 month later...

Here is the modified script to put in a couple of changes that brianbone added to make earthlink on the unraid_notify work.

 

you can use it if you want..  but it's mainly for me when I forget about where I put my modified copy! :-)

(remove the .txt in the file name)

Link to comment
  • 2 months later...

Here is an updated version that more conforms to the berkley standard for mail.  It will either take the old parameters or the standard ones.

 

So

 

Samples Usage:

  cat filename.txt | mail

  echo 'this is a test' | mail

  echo 'this is a test' | mail --subject 'ATTENTION'

  echo 'this is a test' | mail --subject 'ATTENTION' --rcpt [email protected]

 

All still work or...

 

  cat filename.txt | mail

  echo 'this is a test' | mail

  echo 'this is a test' | mail -s 'ATTENTION'

  echo 'this is a test' | mail -s 'ATTENTION' [email protected]

 

Will also work.

 

This still requires unraid_notify to be installed

 

The program is attached..  just remove the .txt

Or the whole package is there too...

 

 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.