Sending CLI emails? notify help?


Recommended Posts

Hi all,

 

I've been trying to get a script working to manage backups and send an email with attachment at the end.

I'm using mailgun as my email sender, and have configured the Notification settings for it in GUI.

 

After much googling and reading, I see that there are 2 (Kind of 3) methods:

- use ssmtp eg (Which invokes sendmail): 

ssmtp [email protected] < /mnt/user/ftp/test_attachment.txt

- use sendmail directly eg: 

ssmtp [email protected] < /mnt/user/ftp/test_attachment.txt

- use the recommended notify (without email): 

/usr/local/emhttp/webGui/scripts/notify -i warning -s "my subject" -d "some description"

I am also trying to get email subsystem of notify to work, without success: 

/usr/local/emhttp/webGui/scripts/notify smtp-init -i normal -s "Subject" -d "Something" -m "Message"

 

Email notifications in the unRAID GUI work when I send a test mail there. I receive the mail in my gmail.

 

The problem is that:

- I cant get Notify to send any email at all, I need an example if possible.

- I cant get ssmtp/sendmail to work, as it sends email as root, and does not work, just like in this old thread. I've tried configuring the revaliases, but I understand this should be avoided.

 

Does anyone know the proper way to send an email using CLI, and would be able to provide an example?

 

Thanks for any help.

 

Edit: When I use sendmail/ssmtp, I get this response basically every time:

[<-] 220 ak47 ESMTP ready
[->] EHLO blaster
[<-] 250 SMTPUTF8
[->] AUTH LOGIN
[<-] 334 VXNlcm5hbWU6
[->] Ymxhc3RlckBzdHJha2VyLm1l
[<-] 334 UGFzc3dvcmQ6
[<-] 235 2.0.0 OK
[->] MAIL FROM:<root@my.domain>
[<-] 250 Sender address accepted
[->] RCPT TO:<target_email@gmail.com>
[<-] 250 Recipient address accepted
[->] DATA
[<-] 354 Continue
[->] Received: by blaster (sSMTP sendmail emulation); Wed, 11 Mar 2020 01:00:14 +0100
[->] From: "Console and webGui login account" <root@my.domain>
[->] Date: Wed, 11 Mar 2020 01:00:14 +0100
[->] 
[->] .
[<-] 250 Great success
[->] QUIT
[<-] 221 See you later. Yours truly, Mailgun

The email sends as `[email protected]` and has no anything, but goes to my spam as an empty email with sender `Console and webGui login account <[email protected]>`.

Help, anyone?

Edited by KptnKMan
Link to comment

Thanks @Squid I'm looking for a way to send only emails, especially with attachments of script logs etc.

I use Pushbullet for my notifications, and I was hoping I could invoke email as a separate thing, as that would be ideal.

 

Do you know if its possible to setup a config for using ssmtp/sendmail? It seems to half work.

Link to comment
  • 1 month later...

I've had some issues with Notify too. I used to send it through my ISP - but it proved far less reliable than using gmail (after turning on 'allow 3rd party apps'). I too was able to use 'test' in the GUI and it worked every time. But scripted, not so good (when using the ISP). Sometimes it didn't work, sometimes it took hours.

 

Do you get any errors when you run it? Here's one of mine that works - when i run it as root.  Are you running yours as root from the terminal?

/usr/local/emhttp/webGui/scripts/notify -e "$(date +"%Y-%m-%d %H:%M")" -s "borg-check >> SUCCESS <<" -d "$BORG_REPO :: Finished successfully ::" -m "Logs :: $LOGFILE" -i "normal"

 

I came here hoping someone out there has successfully run notify without root - i'm 99% sure it used to work but not with 6.8.2 at least.

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.