0

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="[email protected]"

echo "mail body. Something happened here.... hope 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

1
  • 1
    Can you do echo $? and see what return value aer you getting? Also take a look in your mail log file when you run that command. Commented Apr 26, 2011 at 14:08

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

5 Comments

I did a mailq and got this mailq: fatal: open /etc/postfix/main.cf: No such file or directory
yeah looks like your mta isn't configured. are you using sendmail or exim4? I've used exim4 as i found it easier to configure -- the setup process also has a few configuration screens -- just sudo apt-get install exim4
Thank you for your replies. I tried them both but failed. Since this script is a university homework and it will be presented at the lab pcs I will try to execute my script there so that I won't have to setup my ubuntu...(I would like to but I run our time) I will post any new issues..
another thing to remember: mailx is an alias for mail
Thank you all!!! it works fine in the university pc where the mail server is properly setup! I recieved the messages as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.