Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I've been doing this for a while now, using my rsync-based script to email me the rsync log, or my transmission watchdog script email when it restart transmission-daemon (that's relatively new).
So here's my take on how-to email from a script.
The benefit(?) of my approach is that you don't need to install anything to get it to work. My way of doing this uses mutt and msmtp which are already installed. All you need to do is to configure them appropriately. I tried to place those configuration files in a reasonable/standard location.
First, we'll setup msmtp. I setup multiple accounts: My ISP's email and gmail and designated one as the default:(gmail. I, actually, set up a different email for my DNS-323's use)
/ffp/usr/local/etc/msmtprc (see my notes below)
account gmail # certificate file from http://www.geotrust.com/resources/root-certificates/index.html host smtp.gmail.com port 587 from my_user_name@gmail.com tls on tls_starttls on tls_certcheck on tls_trust_file /ffp/etc/ssl/certs/Equifax_Secure_Certificate_Authority.cer auth on user my_user_name password my_long_and_very_secure_passowrd logfile /ffp/var/log/msmtp.log ################################################################################ account isp_name host my.isp.smtp.server port 25 from my_email@isp.host auth off user my_isp_user_name password my_isp_password logfile /ffp/var/log/msmtp.log ################################################################################ account default : gmail
A few important notes:
[*] Make sure that the file only has r/w permissions to the user (root):
chmod 600 /ffp/usr/local/etc/msmtprc
[*] I set up google to use a certificate to authenticate the server. To do that, you need an additional certificate file which I placed in /ffp/etc/ssl/certs/Equifax_Secure_Certificate_Authority.cer. You can either download it from http://www.geotrust.com/resources/root- … index.html (a company google bought) or if you trust me (don't!) - just grab the attached file.
[*] Using your ISP's email may require different settings. Either contact your ISP's tech support, or query your ISP's email server for it's setting use the following command:
msmtp --host=smtp.yourprovider.example --serverinfo
[*] As always, knowledge is power. The official msmtp site has all the documentation: http://msmtp.sourceforge.net/
At this point you already should be able to send an email from the command line. Try the following to test it and don't bother proceeding if it fails:
echo "Test email 123" | msmtp --file=/ffp/usr/local/etc/msmtprc --account=gmail recipient@address
Check the log file /ffp/var/log/msmtp.log to try and figure it doesn't work.
Now that msmtp is configured correctly, let's turn out attention to configuring mutt.
I use the following configuration file.
/ffp/usr/local/share/mutt/Muttrc
set realname="DNS-323" #set from=my_user_name@gmail.com set from=my_email@isp.host set use_from=yes set envelope_from=yes set sendmail= "/usr/bin/msmtp --file=/ffp/usr/local/etc/msmtprc" set sendmail_wait=0 set copy= no my_hdr Auto-Submitted: auto-generated
I use the "set from" line to tell mutt which email to use. Gmail didn't work as reliably as I'd hoped it would (occasionally sending an email would time out).
To test mutt, try the following:
echo "Mutt test email body" | mutt -n -F /ffp/usr/local/share/mutt/Muttrc -s "Mutt test email subject" recipient recipient@address
you could also include attachments, using mutt -a attachment_file
Have fun
Last edited by scaramanga (2012-06-17 15:16:31)
Offline