You are not logged in.
Hello everyone, I'm playing around with shell scripts trying to get the hang of getting them to email me. I'm playing around with this on my laptop, eventually I am going to try to have my server automate some tasks using cron and email me the status. As an experiment I'm just trying to get something simple like a list of packages emailed to myself. I googled around to come up with this script. I also installed postfix and set up the daemon to run. Here is my test script:
#!/bin/bash
# script to send simple email
pacman -Qe > /tmp/packages.txt
# email subject
SUBJECT="Test subject"
# Email To ?
EMAIL="my.email.address"
# Email text/message
EMAILMESSAGE="/tmp/packages.txt"
echo "This is an email message test"> $EMAILMESSAGE
echo "This is email text" >>$EMAILMESSAGE
# send an email using /bin/mail
mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
rm /tmp/packages.txt
However, I don't receive an email.
Note: I withheld my email address above so I don't get spam, but it is in the script.
Last edited by jlacroix (2011-04-11 17:43:01)
Offline
I personally use "sendEmail" (http://aur.archlinux.org/packages.php?ID=7335) so I don't have to setup postfix etc. You may want to try with that to determine if it's a problem with your script or with your postfix installation.
Offline
I personally use "sendEmail" (http://aur.archlinux.org/packages.php?ID=7335) so I don't have to setup postfix etc. You may want to try with that to determine if it's a problem with your script or with your postfix installation.
Thank you for that! I installed it and reviewed the documentation and was successful. If it helps anyone else, here is the code I used (after installing the package) to send myself an email of installed packages, which I can surely use to send myself any report I want:
#!/bin/bash
pacman -Qe > /tmp/packages.txt
sendEmail -f you@yourdomain.com -t smtpusername -u Installed Packages on Computer Name -m These packages are currently installed: -a /tmp/packages.txt -s smtp.server.net:25 -xu smtpusername -xp smtppassword
rm /tmp/packages.txt
Offline
ssmtp is another easy way of doing this
Zygfryd Homonto
Offline
ssmtp is another easy way of doing this
msmtp as well.
Offline
This is not solving your problem, is it?
Don't you wanna know why it didn't work in the first place with the distro included software "mail"?
Try sending an email from the command line and check if you get it...
Regards
My blog: blog.marcdeop.com
Jabber ID: damnshock@jabber.org
Offline