Problem with sending email(to include contents of text file)

Hello,
I was using a shell script for sending contents of a text file(email.report) to different users.
I was using the below command in my script to send email...

cat email.report | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com

It was working fine all these days but now all of a sudden it stopped to send emails...
when i treid to send the mail using below command I will get the mail within a sec.

echo "Hi" | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com

but when I tried include the contents of the text file(as shown in the first code) the mails are not going.
What may be problem?? Why this happend suddenly when the mails are going properly before.. and how to solve this? Pls pls pls help me...
Regards,
Deepak.

When you try to send the report, do you get any errors from the mailx command? What does your local mail-log say?

What is the size of report file? Did you get any error while trying to email the report file?

-Nithin.

try

tail email.report | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com

i didnot get any errors.. but stil not getting mails... i hv used that script for more than 4 months but all of a sudden it is not sending emails!!!

Well, something must have changed between the mailx command and der recipients mailbox. We have to check all steps to see, where things go wrong.

The first step ist the mailx command, which does not output any errors. OK.

The next is your local MDA. Please check its logfile (like /var/log/syslog on Solaris or /var/log/mail.log on Linux). Are there any traces of your mail in this log, especially if the mail was delivered to the next upstream mailserver? A message like "Mail accepted" would indicate, that the problem is not on the sending server.

@hergp..

i go till /var/mail but i cant find syslog or mail.log file inside of it.... :frowning:

---------- Post updated at 06:56 PM ---------- Previous update was at 06:08 PM ----------

tried the above command and got the mail but when i use cat instead of tail i wont get... i want full contents of the mail... pls help...

Good that you can get the email. Looks like your MTA does not like heavy emails. I guess the file is not too big. Check the size email.report

$ du -h email.report

if your "du" does not like -h option just try without it.

If you see the size of file is too big in GB's then size is the problem. If size is not too big then example less than 20-30 MB then there might be some other problem.

Also check the logs of your MTA usually in /var/log/sendmail etc etc ...

Two ways to solve: (I like 2nd way)

  1. Try the max number of lines your MTA likes
$ tail  -n 1000 email.report | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com 
# increase 1000 in step of 1000 till the time you dont get email. 
# Also can try with size check main tail

Method 2:
If you still need the file in email and dont mind as attachment try this

$  tar zcvf email.report.tgz email.report
$ uuencode email.report.tgz email.report.tgz | mailx -s $REQ_SUBJECT -h 5 abc@xyz.com

Hi chakrapani,

when i check

 du email.report

i got the below o/p

8       email.report

then i tried with ur 2nd method of tarring and sending it as attachment but to my badluck i didnot get the email :frowning:

---------- Post updated at 10:31 PM ---------- Previous update was at 10:26 PM ----------

all these days it was working fine y all of a sudden it happened like this? is there any space problem?? i dont know much about unix ... i just use this tool for sending auto email after completing my work...

if i just type mail in my unix prompt i can see lots of old mails... do u think that is creating problem??

---------- Post updated at 10:33 PM ---------- Previous update was at 10:31 PM ----------

and about your first method i didnot get mail in the first attempt itself i mean for 1000 itself i didnot get the mail :frowning:

Yes, it could be a problem.
check if the mail daemon is running properly or not. Do a

ps -ef | grep mail

mail and paste the o/p.
May be you shoud contact your unix admin and have the mail daemon restart.

it will work only till 85... not more than that imean tail -n 85..... :frowning:

---------- Post updated at 10:50 PM ---------- Previous update was at 10:49 PM ----------

this is the output..

9287 27604  0 02:49:27 pts/32    0:00 grep mail

Well, it doesn't look like your mail process is running at all. You should request the admin to start it.

try to send a simple email and see if it is working

mailx -s "Testing" youremail@adress.com

also do a

which mailx

and used the absolute path of the mailx command and try again.

if i send only the below the command i ll get the mail..

tail -n 85 email.report | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com

but note that only till 85 i ll get the mail..if i change that to 86 or more i wont get the mail...!

ok, i see.

can you try

/usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com < email.report

tried.. but didnot get the mail :frowning:

what about this?

( cat email.report) | /usr/bin/mailx -s $REQ_SUBJECT -h 5 abc@xyz.com

that is the one which i tried before without ()... before i was getting mail without any prob with the same script...

well, the last resort which I can think of now is to have the mail daemon restarted.

now i have deleted all the mails which were there in the my unix.. but still my mails are not going... i mean those text files which are having more than 85 lines i am unable to send it.. :frowning: