Solved

SendMail is not worked

Posted on 2002-04-29
46
354 Views
Last Modified: 2013-12-16
I have RedHat Linux 7.2 server with Real IP on the net
From the webmin, I try to send an external email to mmbaba@netways.com, this  email address is real on an external mail server,

Note that :
ServerName is :mylinux
URL of it: http://linux.mynetways.com

the email reforward to my account on linux with the following error:
----------------------------------------------------------

----- The following addresses had permanent fatal errors -----
mmbaba@netways.com
    (reason: 501 5.1.8 <LinuxUser@mylinux.linux.mynetways.com>... Domain of sender
address mostafa@mylinux.linux.mynetways.com does not exist)
----------------------------------------------------------

what is the missing configuration.
0
Comment
Question by:mmbaba
  • 22
  • 18
  • 6
46 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6976886
you have set the domain name (FQDN) of system wrong in the MTA's configuration
0
 

Author Comment

by:mmbaba
ID: 6976892
I have'nt set FQDN ! from where I can set it?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6976908
you used webmin, you should do it there.
Otherwise we need to know which MTA you're using.
0
 

Author Comment

by:mmbaba
ID: 6976926
Sorry You  can clarify what is MTA?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6977085
MTA - Mail Transfer Agent (sometimes simply called : mail server software)
0
 

Author Comment

by:mmbaba
ID: 6977098
Oh, SendMail  (Default setting)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6977146
# set following in your sendmail.cf, then restart sendmail

DMmynetways.com
Djlinux.mynetways.com

# please read comments in this file too
0
 

Author Comment

by:mmbaba
ID: 6977290
Perfect !

the email is reached,

now if I need to send the email from the following perl script:
############
$From='Web@mynetways.com';
open(MAIL,"|/usr/sbin/sendmail -t");
print MAIL <<CORRECT;
Subject: $Subject
To:  mmbaba@netways.com
From:  $From
Reply-To: $ReplyTo

Content-type: text/html

testing
CORRECT
close(MAIL);
############

the script give no error but the mail does'nt reached,

Why my friend !
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6977325
> the email is reached,
and
> the script give no error but the mail does'nt reached,

what's the truth now? I'm confused.

what does /var/log/messages tell you?
what does /var/log/mail tell you?
what does mailq tell you?
0
 

Author Comment

by:mmbaba
ID: 6977341
Perfect !

the email is reached,

now if I need to send the email from the following perl script:
############
$From='Web@mynetways.com';
open(MAIL,"|/usr/sbin/sendmail -t");
print MAIL <<CORRECT;
Subject: $Subject
To:  mmbaba@netways.com
From:  $From
Reply-To: $ReplyTo

Content-type: text/html

testing
CORRECT
close(MAIL);
############

the script give no error but the mail does'nt reached,

Why my friend !
0
 

Author Comment

by:mmbaba
ID: 6977357
Through the webmin the email sendded was reached successfully

but the email sended through the above script not reached

Why ?
0
 
LVL 15

Expert Comment

by:samri
ID: 6977372
mmbaba,

I think I have seen this Q somewhere.

Anyway,  could you check the mail queue.  Do a  "mailq".  Try sending the mail thru command line. Ie:

-------------
/usr/lib/sendmail -v mmbaba@netways.com
Subjet: Test

This is a test
.
-------------

End the line with a single dot (.).  Should everything is OK.  You can see the SMTP conversation took place, and if there is any error, you should be able to see that too.

You can check what had happened to your previous mail.  Look in /var/log/maillog.  There should be someting in there.

And I would presume that DNS setting are OK.  There is an MX entries for netways.com.
0
 

Author Comment

by:mmbaba
ID: 6977405
"...I think I have seen this Q somewhere......"
You are right my self pose a question regarding the slow of the sending mail,
I reinstall the system , now the sending is quickly but through the perl script no mail reach.

this is the result of your suggestion:

# /usr/lib/sendmail -v mmbaba@netways.com
Subject:test
this is a test
.
mmbaba@netways.com... Connecting to mail.netways.com. via esmtp...
220 netways.com ESMTP Sendmail 8.10.2/8.10.2; Mon, 29 Apr 2002 09:53:45 -0400
>>> EHLO linux.mynetways.com
250-netways.com Hello IDENT:KWu60T4Vs60UMQUTFWfbf4gndgq3QMnW@[193.251.166.109], pleased to meet you
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE
250-DSN
250-ONEX
250-ETRN
250-XUSR
250 HELP
>>> MAIL From:<mmbaba@mylinux.linux.mynetways.com> SIZE=28
501 5.1.8 <mmbaba@mylinux.linux.mynetways.com>... Domain of sender address mmbaba@mylinux.linux.mynetways.com does not exist
mmbaba... Connecting to local...
mmbaba... Sent
Closing connection to mail.netways.com.
>>> QUIT
221 2.0.0 netways.com closing connection
You have new mail in /var/spool/mail/mmbaba
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6977423
oops, see samri's . (dot) comment
0
 

Author Comment

by:mmbaba
ID: 6977455
Dears, then

I have 2 methods to send mails

1- through the webmin
   Compose> he fill the input box of From by default (after  ahoffmann  ) by : mmbaba@mynetways.com

If I send mail , ===>it reach
  and If I take off the input box of From  ==>the email do not reach

2- through the script ====> he do not reach.
0
 
LVL 15

Expert Comment

by:samri
ID: 6977513
mmbaba,

I think I have seen this Q somewhere.

Anyway,  could you check the mail queue.  Do a  "mailq".  Try sending the mail thru command line. Ie:

-------------
/usr/lib/sendmail -v mmbaba@netways.com
Subjet: Test

This is a test
.
-------------

End the line with a single dot (.).  Should everything is OK.  You can see the SMTP conversation took place, and if there is any error, you should be able to see that too.

You can check what had happened to your previous mail.  Look in /var/log/maillog.  There should be someting in there.

And I would presume that DNS setting are OK.  There is an MX entries for netways.com.
0
 
LVL 15

Expert Comment

by:samri
ID: 6977526
gee.. sorry for the repeated posts. (blamed it on InterQuick).
0
 
LVL 15

Expert Comment

by:samri
ID: 6977599
Watch these two lines;

250-netways.com Hello IDENT:KWu60T4Vs60UMQUTFWfbf4gndgq3QMnW@[193.251.166.109], pleased to meet you
501 5.1.8 <mmbaba@mylinux.linux.mynetways.com>... Domain of sender address mmbaba@mylinux.linux.mynetways.com


I think there is something to do with reverse lookup.  

Another strange this is that the Masquerading doesn't seems to work.

Look a few posts back, there should be a comment by ahoffman's on how to get the masquerading.  I would presume that you machine would be "mylinux", and your domain would be "mynetsys.com", so you might want to add DMmynetsys.com in your sendmail.cf (by default it is left blank - I think).  Make sure you restart sendmail --- most of this thing has been touched by ahoffman's too.

Alternately, you can use the sendmail.mc file in /etc/mail.  Just add a line;

MASQUERADE_DOMAIN(netsys.com)dnl

Detailed info on Sendmail's website.
http://www.sendmail.org/m4/masquerading.html

After that save the file, and do a "m4 sendmail.mc > sendmail.cf.  Remember to make a copy of the original sendmail.cf, just in case, I screwed-up.   I think "make sendmail.cf" might work.

About the DNS issue, make sure your host is defined in the DNS (fwd and reverse entry).  Alternately you could add the entry in /etc/hosts of the remote Relay.  Go for the 1st option just in case you might be sending mail directly out to remote sendmail (and not using any relay).

I hope this should help.

The explanation why your mail went thru via Webmin - I think webmin has it's own MUA (mail User Agent) - just like Mail::Sendmail perl module, which connects directly to the remote Sendmail, and does the delivery for you.  Whereas sending mail from cmd line - you are sending the mail to your local Sendmail which then, connect to remote SMTP to relay the mail.  (Gee... I might have made everybody's confused :)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6977606
well, if you can send mail using a standard MUA (like mail, pine, etc.) then this question is fixed.
Sending mails through perl is another question/problem, where the web server is involved too.
0
 

Author Comment

by:mmbaba
ID: 6979777
dear,  ahoffmann  the aim of my question is to fix the sending mails  through perl scripts but to facilate things I was starting talk about the webmin , to let us sure that the connection with the internet have no problem to sending mails, and the problem is in the configuration trend.

I tied the above , no real  progress happend
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6979832
just to clarify where we stand:
can you send mail with "mail", "pine", etc., and are they elivered correctly? yes or no
0
 

Author Comment

by:mmbaba
ID: 6979902
let us focus on sendmail service

my DNS is linux.mynetways.com (I call it externallly as http://linux.mynetways.com)
Local hostname is : mylinux (I call it internally as http://mylinux)

If I send mail I do not know why he respnse as following?

Domain of sender address mmbaba@mylinux.linux.mynetways.com does not exist

I tried putting From:mmbaba@mynetways.com but it generate the some result.

Note: through webmin if I left From section empty it generate the same problem but If I put From:mmbaba@mynetways.com
the email sent successfully .
0
 
LVL 15

Expert Comment

by:samri
ID: 6979942
The DNS has this record

in mynetways.com zone;
-----
linux.mynetways.com.   in   a 1.2.3.4
in 3.2.1.in-adrr.arpa. zone;
-----
4          in ptr linux.mynetways.com.

I think what had happened is that when your sendmail tries to connect to remote smtp, the remote server failed to do reverse lookup on your name (since your are using mylinux).

Try to stick to one name, preferably the one already in DNS, and if the entry is yet in the DSN, add one, both for fwd and rev lookup zone.  

* Remember to increase the serial number in the SOA record too.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:mmbaba
ID: 6979963
Sorry in which file?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6980001
# is following set in sendmail.cf
DMmynetways.com
Djlinux.mynetways.com

# please post result of:  grep ^DS sendmail.cf
0
 

Author Comment

by:mmbaba
ID: 6980026
1-Yes they are there.
2-Result:
[root@mylinux etc]# grep ^DS sendmail.cf
DS
[root@mylinux etc]#
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6980190
please post results of:

sendmail -bv mmbaba@netways.com
echo 3 mmbaba@netways.com|sendmail -bt
echo 6 mmbaba@netways.com|sendmail -bt
0
 

Author Comment

by:mmbaba
ID: 6980231
bash-2.05$ /usr/lib/sendmail -bv mmbaba@netways.com
mmbaba@netways.com... deliverable: mailer esmtp, host netways.com., user mmbaba@netways.com

bash-2.05$ /usr/lib/echo 3 mmbaba@netways.com|sendmail -bt
bash: /usr/lib/echo: No such file or directory
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6980716
/usr/lib/echo ? who said this?
Just use echo
0
 

Author Comment

by:mmbaba
ID: 6980749
[root@mylinux]# echo 3 mmbaba@netways.com|sendmail -bt
bash: sendmail: command not found
0
 
LVL 15

Expert Comment

by:samri
ID: 6980761
ahoffmans,

sendmail -bv mmbaba@netways.com <-- this one might failed without full path (I think.).

i'm getting tired of 28kbps dialup :(
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6980861
mmbaba, please look what you've found yourself, and you posted it also here:
      /usr/lib/sendmail

mmbaba, samri,
I didn't use full paths, 'cause we're in a Linux TA, and a lot of Linux distributions deliver with /usr/sbin/sendmail, while traditional UNIX (Solaris, HP-UX, etc.) come with  /usr/lib/sendmail.
Linux is strange in this :-(
0
 

Author Comment

by:mmbaba
ID: 6980890
Sorry:

#echo 3 mmbaba@netways.com|/usr/lib/sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> canonify           input: mmbaba @ netways . com
Canonify2          input: mmbaba < @ netways . com >
Canonify2        returns: mmbaba < @ netways . com . >
canonify         returns: mmbaba < @ netways . com . >


#echo 6 mmbaba@netways.com|/usr/lib/sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> 6                  input: mmbaba @ netways . com
6                returns: mmbaba @ netways . com
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6981002
according to postings (and if you did not change the rules in sendmail.cf, which I don't assume:), sendmail works, and delivers mail.

If it delivers locally and not to other domains, it's most likely a DNS problem. unfortunately sendmails default behaviour is to use MX records from DNS, newer sendmail can be tweaked to use /etc/hosts instead.

If you still get some error, please post the command you used verbatim, also post **all** messages verbatim you get, and check your log files (/var/log/{mail,messages} and/or whatever you've setup in sendmail.cf and/or /etc/syslog.conf), post important messages too.
0
 

Author Comment

by:mmbaba
ID: 6985311
"...please post the command you used verbatim, also post **all** messages verbatim ..."

I agree you that the problem it could be a MX record problem but you can clarify what do you mean in the above sentence.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6985375
whcich command did you use to send mail, please post it as you used it (all parameters), and which result you get (mail or not, messages in log files).
Please use copy&paste and do not rewrite commands and messages here, for obvious reason ;-)
0
 

Author Comment

by:mmbaba
ID: 6985397
I'm testing the issue as following

----------------------------
# /usr/lib/sendmail -v mmbaba@netways.com
From:mmbaba@mynetways.com
Subject:test
this is a test
.
----------------------------
Result:

mmbaba@netways.com... Connecting to mail.netways.com. via esmtp...
220 netways.com ESMTP Sendmail 8.10.2/8.10.2; Mon, 29 Apr 2002 09:53:45 -0400
>>> EHLO linux.mynetways.com
250-netways.com Hello IDENT:KWu60T4Vs60UMQUTFWfbf4gndgq3QMnW@[193.251.166.109], pleased to meet you
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE
250-DSN
250-ONEX
250-ETRN
250-XUSR
250 HELP
>>> MAIL From:<mmbaba@mylinux.linux.mynetways.com> SIZE=28
501 5.1.8 <mmbaba@mylinux.linux.mynetways.com>... Domain of sender address mmbaba@mylinux.linux.mynetways.com
does not exist
mmbaba... Connecting to local...
mmbaba... Sent
Closing connection to mail.netways.com.
>>> QUIT
221 2.0.0 netways.com closing connection
You have new mail in /var/spool/mail/mmbaba
--------------------------------------------
look that he add atomaticaly the following:

<mmbaba@mylinux.linux.mynetways.com>

and I do not know why he take off after @ mynetways.com and replace it by :mylinux.linux.mynetways.com

note: I was sayeing that mylinux is the local host and
My url is http://linux.myntways.com

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6985463
<
  >>> MAIL   From:<mmbaba@mylinux.linux.mynetways.com> SIZE=28501 5.1.8 <mmbaba@mylinux.linux.mynetways.com>...
  Domain of sender address mmbaba@mylinux.linux.mynetways.com does not exist
>

This tells you 2 things:
1. the Dj is set wrong in sendmail.cf (or you didnot restart the sendmail deamon after changing)
2. connection to netways.com was successful, but it rejects delivering mail 'cause it canot find a mail exchanger (MX) for mylinux.linux.mynetways.com
  this could either be 'cause of 1. (see above), or 'cause there is no MX in you DNS for mynetways.com.
  (BTW, such a behaviour of netways.com is called "relaying denied", sometimes)
0
 

Author Comment

by:mmbaba
ID: 6985802
"...Dj is set wrong in ...."

my settings is :
DMmynetways.com
Djlinux.mynetways.com

I restart my Server and I'm sure.

".....it canot find a mail exchanger (MX) for mylinux.linux.mynetways.com......"

I forword my research in this target,

do you have a suggestion  regarding that !
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6986874
silly question: is there more than one Dj in sendmail.cf?

The MX record must be set in your DNS configuration, somthing like_

@ IN MX 50 mail.mynetworks.com.

of course, it must be a primary DNS, so it can be reached always, anywhere, ..
0
 

Author Comment

by:mmbaba
ID: 6987967
"....is there more than one Dj in sendmail...."

No one time.

regarding MX record, can you guide me in which file I should change ?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6988084
> .. which file I should change
check /etc/named.conf where the database files for named reside (directory keyword), then edit the appropriate file, adding a line like from my last comment. Restart named.
0
 

Author Comment

by:mmbaba
ID: 6993844
dear ahoffmann,

I have a remark, I sent to an account of hotmail and another to the yahoo, and the mail reached successfully, look:

------------
/usr/lib/sendmail -v assem_houmsy@hotmail.com
Subject:testtttt
asdas
.
assem_houmsy@hotmail.com... Connecting to mx06.hotmail.com. via esmtp...
220-HotMail (NO UCE) ESMTP server ready at Tue, 07 May 2002 06:00:56 -0700
220 ESMTP spoken here
>>> EHLO linux.mynetways.com
250-hotmail.com Hello
250-8bitmime
250 SIZE 1572864
>>> MAIL From:<mostafa@mylinux.linux.mynetways.com> SIZE=23
250 Requested mail action okay, completed
>>> RCPT To:<assem_houmsy@hotmail.com>
250 Requested mail action okay, completed
>>> DATA
354 Start mail input; end with <CRLF>.<CRLF>
>>> .
250 Requested mail action okay, completed
assem_houmsy@hotmail.com... Sent (Requested mail action okay, completed)
Closing connection to mx06.hotmail.com.
>>> QUIT
------------
then the problem it could be not in my sever !

I have an access to the mail.netways.com what can I do  to let it recive mails sended by my local server. ?
0
 

Author Comment

by:mmbaba
ID: 6993849
dear ahoffmann,

I have a remark, without any change in the MX record, I sent to an account of hotmail and another to the yahoo, and the mail reached successfully, look:

------------
/usr/lib/sendmail -v assem_houmsy@hotmail.com
Subject:testtttt
asdas
.
assem_houmsy@hotmail.com... Connecting to mx06.hotmail.com. via esmtp...
220-HotMail (NO UCE) ESMTP server ready at Tue, 07 May 2002 06:00:56 -0700
220 ESMTP spoken here
>>> EHLO linux.mynetways.com
250-hotmail.com Hello
250-8bitmime
250 SIZE 1572864
>>> MAIL From:<mostafa@mylinux.linux.mynetways.com> SIZE=23
250 Requested mail action okay, completed
>>> RCPT To:<assem_houmsy@hotmail.com>
250 Requested mail action okay, completed
>>> DATA
354 Start mail input; end with <CRLF>.<CRLF>
>>> .
250 Requested mail action okay, completed
assem_houmsy@hotmail.com... Sent (Requested mail action okay, completed)
Closing connection to mx06.hotmail.com.
>>> QUIT
------------
then the problem it could be not in my sever !

I have an access to the mail.netways.com what can I do  to let it recive mails sended by my local server. ?
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 6994329
> then the problem it could be not in my sever !
what do you mean by server?
  hardware, sendmail MTA, named, ...
If the remote MTA does not check your address, it might be true. If it checks, you need a valid MX in DNS

> .. what can I do  to let ..
first check the logs, then check if it denies relaying.
0
 

Author Comment

by:mmbaba
ID: 7026558
dear, I find where  should change

from webmin>hardware>Network Configuration >Host Addresses >choose my real IP> change the related hostname from:
mylinux.linux.mynetways.com

to :mynetways.com

and now the out put messages through the command

/usr/lib/sendmail -v mmbaba@netways.com

has as from: myuser@mynetways.com

and the testing is perfect , thanks for your efforts.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now