I want to send an email from a bash script when my script creates a new file.
This is the code I have written so far:
SUBJECT="MyNotifier"
TO="nobody@gmail.com"
echo "mail body. Something happened here.... ho开发者_JAVA技巧pe you get this!" | mailx -s "$SUBJECT" "$TO"
The point is I don't get any error messsages neither mails.
I have only downloaded and instaled mailx (with the sudo apt-get command - excuse me I am noob)
I haven't configured it at all.
What am I doing wrong? Thanks in advance
Quite likely your sendmail/exim server isn't configured -- and as such the emails are being sent to the MTA (mail transport agent) but are left in the queue. If you issues a mailq
command you should see the list of mails currently waiting to be sent -- if there are mails in the queue then you need to configure your MTA, if there are no mails in the mailq then your emails were sent but were probably discarded by the receiver (there are many reasons why this would happen -- and you can find lots of resources on google on it, however a very common one is if your sender domain doesn't map back to the ip you sent an email from).
精彩评论