Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bash mail not working

Status
Not open for further replies.

aalnaif

Technical User
Jan 12, 2007
44
CA
I wrote the following simple bash script to send mail:
Code:
#!/bin/bash
SUBJECT="testsubj"
EMAIL="username@domain.com"
EMAILMESSAGE="/tmp/emailmessage.txt"

echo "testbody">$EMAILMESSAGE
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
The script runs fine (no errors are returned), but username@domain.com never received an email. Does anyone know what can possibly be the problem? Does something need to be configured?
 
can your system resolv domain.com?

run

tail -f /var/log/maillog

on a separate terminal and try sending the message again.


QatQat

If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
When I run tail -f /var/log/maillog, I see:

Code:
Mar 30 10:21:38 localhost sendmail[7919]: 12UGLcmM007919: from=local_user, size=55, class=0, nrcpts=1, msgid=<200703301621.12UGLcmM007919@localhost.localdomain>, relay=local_user@localhost
Mar 30 10:21:38 localhost sendmail[7919]: 12UGLcmM007919: to=username@domain.com, ctladdr=local_user (504/505), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30055, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

Notice the last line - "Connection refused by [127.0.0.1]
 
is any MTA running on your system?

Are you running RH linux, debia, etc...


Normally you should have sendmail installed; to get mail working just start sendmail, no particular configuration needed.
Obvioulsy that MTA will not go much further without approprioate configuration but it should do the trick for you.

QatQat

If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
I am running Linux Fedora Core 5. I re-installed sendmail, and then restarted the sendmail service, and then ran the script shown in my first post again. But username@domain.com still isn't receiving the email. Here is what I see in the maillog now:

Code:
Mar 31 10:16:25 localhost sendmail[19026]: l2VGGP8x019026: from=root, size=55, class=0, nrcpts=1, msgid=<200703311616.l2VGGP8x019026@localhost.localdomain>, relay=root@localhost
Mar 31 10:16:25 localhost sendmail[19027]: l2VGGP8F019027: from=<root@localhost.localdomain>, size=359, class=0, nrcpts=1, msgid=<200703311616.l2VGGP8x019026@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Mar 31 10:16:25 localhost sendmail[19026]: l2VGGP8x019026: to=username@domain.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30055, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (l2VGGP8F019027 Message accepted for delivery)
Mar 31 10:16:26 localhost sendmail[19029]: l2VGGP8F019027: to=<username@domain.com>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120359, relay=inbound.aztecamobi...om.netsolmail.net. [205.178.149.7], dsn=5.0.0, stat=Service unavailable
Mar 31 10:16:26 localhost sendmail[19029]: l2VGGP8F019027: l2VGGQ8F019029: DSN: Service unavailable
Mar 31 10:16:26 localhost sendmail[19030]: l2VGGQ8F019029: Warning: program /usr/bin/procmail unsafe: Group writable directory
Mar 31 10:16:26 localhost sendmail[19029]: l2VGGQ8F019029: to=<root@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31618, dsn=2.0.0, stat=Sent
 
Did you configure the system to use 205.178.149.7 (mail.networksolutionsemail.com) as a relay? Are you sure you have access to use that relay?

Annihilannic.
 
Is there a way not to use the mail.networksolutionsemail.com relay?
 
/etc/mail/mailertable is an empty file
 
What domain are you sending email to? Is it related to Network Solutions in any way? Do you know whether there is a smart relay on your network, or are you directly connected to the internet?

Annihilannic.
 
Yes I am sending email to the Network Solutions domain, but I am directly connected to the internet, so I don't want to use a relay. I just want to send mail directly.
 
Well, for some reason their domain isn't accepting your connection; you need to check with them. Does email to anywhere else work?

It may be for security reasons; if your system's IP address is not in DNS for example?

Annihilannic.
 
Do I have to initialize, set up, or configure sendmail in any way, or should it just work?
 
normally, as long as sendmail is running, mail command should work.

Can you send any email using an email client (i.e. kmail, thunderbird, etc...) relaying on that smtp server?

If so, try set it as smart host in sendmail.mc.

watch the syntax (` and not ').

after modifying the smart host line do

make
service sendmail restart

Before you try again, make sure hat your DNS settings are ok and your box can resolve domains.

verify that in /etc/resolv.conf



QatQat

If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top