Mail sending

Dear all,
how can i send mail using mailx or mail command?do i need to configure anything for sending mail?please help me.Its urgent.
the version i use is
Linux TDM 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003 i686 i686 i386 GNU/Linux

Thanks
Regards,
Pankaj

Hey

YOu don;t need to configure any thing, but ya make sure that your varsion have reference to command mail or mailx.

cat file1 | mailx -s $Subject $MailRecievers

file1 having the contents to be mailed.
$Subject having title of the mail
$MailRecievers haveing names of the mail recievers.

or

echo "Alter, Boss is there !! " | mailx -s "Boss" "abc.com"

Hope you got this !!
Otherwise goto "man mail" and explore it !:b:

For sending the mails thru CLI via mail and mailx, You must have SMTP server. If you have SMTP Server you can use mail or mailx to sending the mails.

mail -s "Subject Whatever you want" user@your-domain.com < File_Name

File_Name file is contains contents for your mail body.

Dear Sanjay,
thanks for your kind help but i have tried with you have suggested but not working
i have triedmail -s "test" pankaj.choudhury@tcs.com < hi
but its not working.

thanks
regards
pankaj

Lets try step by step

1:- First check do you have SMTP service on in your Linux/UnixBox or not
Then create one file
> echo " Hi this is just for testing" >/tmp/testmail

Then send it via mail command

> mail -s "Testing" pankaj.choudhury@tcs.com < /tmp/testmail

Try to see the logs

> tail -n 50 /var/log/messages

If it will not work send me the log mesages, so I will suggest you somthing in better way

So Dun worry !!! Start

Dear Sanjay,
as you suggested me i'm sending you the log

Sep 17 21:04:54 TDM nmbd[8255]: [2007/09/17 21:04:54, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 17 21:04:54 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 17 21:04:54 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 17 21:29:55 TDM nmbd[8255]: [2007/09/17 21:29:55, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 17 21:29:55 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 17 21:29:55 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 17 21:54:55 TDM nmbd[8255]: [2007/09/17 21:54:55, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 17 21:54:55 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 17 21:54:55 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 18 00:44:57 TDM nmbd[8255]: [2007/09/18 00:44:57, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 00:44:57 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 00:44:57 TDM nmbd[8255]: This response was from IP 172.17.181.234, reporting an IP address of 172.17.181.234.
Sep 18 03:59:57 TDM nmbd[8255]: [2007/09/18 03:59:57, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 03:59:57 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 03:59:57 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 18 04:49:58 TDM nmbd[8255]: [2007/09/18 04:49:58, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 04:49:58 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 04:49:58 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 18 05:24:58 TDM nmbd[8255]: [2007/09/18 05:24:58, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 05:24:58 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 05:24:58 TDM nmbd[8255]: This response was from IP 172.17.181.234, reporting an IP address of 172.17.181.234.
Sep 18 06:39:58 TDM nmbd[8255]: [2007/09/18 06:39:58, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 06:39:58 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 06:39:58 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 18 07:39:59 TDM nmbd[8255]: [2007/09/18 07:39:59, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 07:39:59 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 07:39:59 TDM nmbd[8255]: This response was from IP 172.17.182.16, reporting an IP address of 172.17.182.16.
Sep 18 08:04:58 TDM nmbd[8255]: [2007/09/18 08:04:58, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 08:04:58 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 08:04:58 TDM nmbd[8255]: This response was from IP 172.17.181.234, reporting an IP address of 172.17.181.234.
Sep 18 09:29:58 TDM nmbd[8255]: [2007/09/18 09:29:58, 0] nmbd/nmbd_namequery.c:query_name_response(101)
Sep 18 09:29:58 TDM nmbd[8255]: query_name_response: Multiple (2) responses received for a query on subnet 172.17.181.187 f
Sep 18 09:29:58 TDM nmbd[8255]: This response was from IP 172.17.181.234, reporting an IP address of 172.17.181.234.
Sep 18 09:49:11 TDM su(pam_unix)[9357]: session opened for user tdmscrdr by tdmscrdr(uid=504)
Sep 18 10:09:18 TDM smbd[19543]: [2007/09/18 10:09:18, 0] smbd/service.c:make_connection(850)
Sep 18 10:09:18 TDM smbd[19543]: 01hw084873 (172.17.180.191) couldn't find service .
Sep 18 11:14:46 TDM su(pam_unix)[12282]: session opened for user oracle by tdmscrdr(uid=504)
Sep 18 12:02:10 TDM su(pam_unix)[12282]: session closed for user oracle
Sep 18 12:16:28 TDM su(pam_unix)[15689]: session opened for user oracle by tdmscrdr(uid=504)
Sep 18 12:35:51 TDM su(pam_unix)[15689]: session closed for user oracle
Sep 18 13:01:58 TDM su(pam_unix)[18492]: session opened for user oracle by tdmscrdr(uid=504)
Sep 18 13:03:23 TDM su(pam_unix)[18492]: session closed for user oracle
Sep 18 14:36:38 TDM su(pam_unix)[22812]: session opened for user oracle by tdmscrdr(uid=504)
Sep 18 14:36:49 TDM su(pam_unix)[22812]: session closed for user oracle
Sep 18 14:37:22 TDM su(pam_unix)[22941]: authentication failure; logname=tdmscrdr uid=504 euid=0 tty= ruser=tdmscrdr rhost=
Sep 18 14:37:31 TDM su(pam_unix)[22944]: session opened for user oracle by tdmscrdr(uid=504)
Sep 18 14:59:17 TDM su(pam_unix)[23858]: session opened for user oracle by tdmscrdr(uid=504)
Sep 18 15:42:45 TDM su(pam_unix)[26395]: authentication failure; logname=tdmscrdr uid=503 euid=0 tty= ruser=tdmscrndr rhost=
Sep 18 15:48:05 TDM su(pam_unix)[27317]: session opened for user root by tdmscrdr(uid=503)
Sep 18 15:50:57 TDM su(pam_unix)[27317]: session closed for user root

thnx
regards,
Pankaj

It seems to me your Linux/Unix box very busy so just give me the logs

grep -i "pankaj.choudhury@tcs.com" /var/log/messages

Because I didn't get any logs related to your SMTP, So send me the output of above command.

Dear sanjay,
there is no such info regarding pankaj.choudhury@tcs.com.i think it means its not performing the job of mail sending

thnx,
regards,
pankaj

Humm

Then check there any mail logs directory within /var/log directory.
might be you have seprate log directory for the maillog.

and send me the output of given command

1:- chkconfig --list | grep mail

Daer sanjay,
please go through this

Sep 18 16:01:51 TDM sendmail[27979]: l8IAVmpj027977: l8IAVppj027979: DSN: Data format error
Sep 18 16:01:52 TDM sendmail[27979]: l8IAVppj027979: to=<tdmscrdr@TDM>, delay=00:00:01, mailer=local, pri=31347, dsn=4.4.3, s
Sep 18 16:02:51 TDM sendmail[27997]: My unqualified host name (TDM) unknown; sleeping for retry
Sep 18 16:04:22 TDM sendmail[27997]: unable to qualify my own domain name (TDM) -- using short name
Sep 18 16:04:22 TDM sendmail[27997]: l8IAYMR0027997: from=tdmscrdr, size=70, class=0, nrcpts=1, msgid=<200709181034.l8IAYMR00
mscrdr@localhost
Sep 18 16:04:54 TDM sendmail[28150]: l8IAYNpj028150: from=<tdmscrdr@TDM>, size=323, class=0, nrcpts=1, msgid=<200709181034.l8
roto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Sep 18 16:04:54 TDM sendmail[27997]: l8IAYMR0027997: to=pankaj.choudhury@tcs.com, ctladdr=tdmscrdr (504/500), delay=00:00:32,
iler=relay, pri=30070, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (l8IAYNpj028150 Message accepted for delivery)
Sep 18 16:04:54 TDM sendmail[28175]: STARTTLS=client, relay=inkolg01.tcs.com., version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-R
256/256
Sep 18 16:04:54 TDM sendmail[28175]: l8IAYNpj028150: to=<pankaj.choudhury@tcs.com>, ctladdr=<tdmscrdr@TDM> (504/500), delay=0
0:00, mailer=esmtp, pri=30323, relay=inkolg01.tcs.com. [172.18.18.26], dsn=5.6.0, stat=Data format error
Sep 18 16:04:54 TDM sendmail[28175]: l8IAYNpj028150: l8IAYspj028175: DSN: Data format error
Sep 18 16:04:54 TDM sendmail[28175]: l8IAYspj028175: to=<tdmscrdr@TDM>, delay=00:00:00, mailer=local, pri=31347, dsn=4.4.3, s
Sep 18 16:25:05 TDM sendmail[29130]: My unqualified host name (TDM) unknown; sleeping for retry
Sep 18 16:26:36 TDM sendmail[29130]: unable to qualify my own domain name (TDM) -- using short name
Sep 18 16:26:36 TDM sendmail[29130]: l8IAuaaX029130: from=tdmscrdr, size=76, class=0, nrcpts=1, msgid=<200709181056.l8IAuaaX0
mscrdr@localhost
Sep 18 16:27:08 TDM sendmail[29203]: l8IAubpj029203: from=<tdmscrdr@TDM>, size=329, class=0, nrcpts=1, msgid=<200709181056.l8
roto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Sep 18 16:27:08 TDM sendmail[29130]: l8IAuaaX029130: to=pankaj.choudhury@tcs.com, ctladdr=tdmscrdr (504/500), delay=00:00:32,
iler=relay, pri=30076, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (l8IAubpj029203 Message accepted for delivery)
Sep 18 16:27:10 TDM sendmail[29223]: STARTTLS=client, relay=indelg01.tcs.com., version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-R
256/256
Sep 18 16:27:11 TDM sendmail[29223]: l8IAubpj029203: to=<pankaj.choudhury@tcs.com>, ctladdr=<tdmscrdr@TDM> (504/500), delay=0
0:03, mailer=esmtp, pri=30329, relay=indelg01.tcs.com. [157.227.246.120], dsn=5.6.0, stat=Data format error
Sep 18 16:27:11 TDM sendmail[29223]: l8IAubpj029203: l8IAvBpj029223: DSN: Data format error
Sep 18 16:27:11 TDM sendmail[29223]: l8IAvBpj029223: to=<tdmscrdr@TDM>, delay=00:00:00, mailer=local, pri=31353, dsn=4.4.3, s

Thnx
Regards,
pankaj

Find out your ip address of your system by using "ifconfig" command
then find out your host name by using "hostname" command

#ifconfig<whatever the ip address> example
172.17.21.23
#hostname
< what ever the out will come > Example
tdm

then Just edit your /etc/hosts file
127.0.0.1 localhost tcs.com
127.0.0.1 localhost.localdomain localhost
172.17.21.23 tdm.tcs.com tdm TDM
----------------------------------------------
Let me explain you

this error appears to be caused in several ways, most related to DNS
name service. A few:

  1. if your sending machine does not have it's own name/IPaddress in
    its /etc/hosts file, it will cause the upstream target/relay host
    to reject the message with something which means: "I don't know who
    you are". The sending MTA sendmail then issues the error in the
    maillog "...dsn=5.6.0 stat=Data Format Error". The fix for this is
    to have a correct /etc/hosts; like so why i asked you to ediet the /etc/hosts file

And I am 100 % sure it will work for you

!!!BINGO!!!!!!!!

Dear Sanjay
i have done as u suggested.plz look into that...i have mail u the logs nd all the things...and plz suggest me

regards,
thanx
pankaj

Dear sanjay,
can u plz help me out? as u suggested i have sone the same
ip address is 172.12.181.187
hostname is TDM

plz suggest me.
do i need to configure anything else? something like mailconfig?
every time i'm getting from the /var/log/maillog is

Sep 19 10:09:08 TDM sendmail[10486]: l8ICRapj002154: to=<tdmscrdr@TDM.tcs.com>, delay=16:11:32, xdelay=00:00:00, mailer=esmtp, pri=1561377, relay
=tdm.tcs.com., dsn=4.0.0, stat=Deferred: Connection refused by tdm.tcs.com.

why this connection is refused?

plz reply

thanx,
regards,
pankaj

I checked the logs provided by you.
It seems to me you didn't configured your sendmail proeprly.
Do the following steps.

you need to edit the /etc/mail/sendmail.mc file. There you need to search line "dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')"
and then delete dnl. Now this line should be DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
Save it and exit. Then you need to run below given command.

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Then restart your sendmail service.

# service sendmail restart

or

# /etc/init.d/sendmail restart

Now you will able to send the mail from your system.

Thanks

Sanjay Tripathi

Dear sanjay i have tried with like this

vi hosts

127.0.0.1 localhost tcs.com
127.0.0.1 localhost.localdomain localhost
172.17.181.187 tcs.com TDM

then i have saved it nd then sent the mail

the log is

Sep 19 10:24:26 TDM sendmail[12098]: l8J4sOpj012096: to=<pankaj.choudhury@tcs.com>, delay=00:00:02, xdelay=00:00:01, mailer=esmtp, pri=30341, rel
ay=inchng01.tcs.com. [172.20.93.63], dsn=2.0.0, stat=Sent (ok: Message 106713846 accepted)

but not still not came to my mail id

thnx,
regards,
pankaj

Dear sanjay,
i have done the same as u suggested...getiing this

Sep 19 10:43:17 TDM sendmail[13940]: /etc/mail/sendmail.cf: WARNING: dangerous write permissions
Sep 19 10:43:17 TDM sendmail[13940]: NOQUEUE: SYSERR(root): No local mailer defined
Sep 19 10:43:17 TDM sendmail[13940]: NOQUEUE: SYSERR(root): QueueDirectory (Q) option must be set
Sep 19 10:43:17 TDM sendmail[13945]: /etc/mail/sendmail.cf: WARNING: dangerous write permissions
Sep 19 10:43:17 TDM sendmail[13945]: NOQUEUE: SYSERR(root): No local mailer defined
Sep 19 10:43:17 TDM sendmail[13945]: NOQUEUE: SYSERR(root): QueueDirectory (Q) option must be set
Sep 19 10:43:17 TDM sm-msp-queue[13953]: starting daemon (8.12.10): queueing@01:00:00
Sep 19 10:43:57 TDM sendmail[14000]: /etc/mail/sendmail.cf: WARNING: dangerous write permissions
Sep 19 10:43:57 TDM sendmail[14000]: NOQUEUE: SYSERR(root): No local mailer defined
Sep 19 10:43:57 TDM sendmail[14000]: NOQUEUE: SYSERR(root): QueueDirectory (Q) option must be set
Sep 19 10:43:57 TDM sendmail[14005]: /etc/mail/sendmail.cf: WARNING: dangerous write permissions
Sep 19 10:43:57 TDM sendmail[14005]: NOQUEUE: SYSERR(root): No local mailer defined
Sep 19 10:43:57 TDM sendmail[14005]: NOQUEUE: SYSERR(root): QueueDirectory (Q) option must be set
Sep 19 10:43:57 TDM sm-msp-queue[14013]: starting daemon (8.12.10): queueing@01:00:00
Sep 19 10:44:37 TDM sendmail[14047]: l8J5EbsH014047: from=tdmscrdr, size=76, class=0, nrcpts=1, msgid=<200709190514.l8J5EbsH014047@tcs.com>, rela
y=tdmscrdr@localhost
Sep 19 10:44:37 TDM sendmail[14047]: l8J5EbsH014047: to=pankaj.choudhury@tcs.com, ctladdr=tdmscrdr (504/500), delay=00:00:00, xdelay=00:00:00, ma
iler=relay, pri=30076, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

from log

thnx,
regards,
pankaj