Mailx , sendmail and mailhost

Hi all,

I am trying to grasp the concept between the 3 entity above.

I understand that mailx - MUA
I also understand that sendmail = MTA

1) If I have a centralized mail server (which might not be sendmail), can I just set mailhost in "/etc/hosts" to point to that mailserver and use mailx to send out the email ?

Does sendmail need to be involved in the process above ?

or

2) I need to have a sendmail running locally on the server, and have mailx send the mail to the sendmail, before sendmail send out to the "centralized mail server" ?

If mailx is using the local sendmail to send out mail, what should set at the "mailhost" parameter in /etc/hosts ?

if mailhost parameter meant for mailx or sendmail ? :confused::confused:

=========================

It seems that mailx does not work, if i did not turn on my sendmail service, and mailx -v shows that it is connecting locally to 127.0.0.1.

However, whichever email address i send to , it seems that mailx is always sending to 127.0.0.1 even thought i have set "mailhost" in /etc/hosts to point to another server.

is mailhost here being referred to at all ? or sendmail will use it to relay the mail ?

Hope some gurus can shed some light on this.

Thanks!

Regards,
Noob

Let's start from the beginning.
sendmail has to be running as (often) two daemons often started two ways (not always). The configuration files are:

/etc/mail/sendmail.cf	#Defines environment for sendmail
/etc/mail/submit.cf	#Defines environment for MSP (Mail submission program)
/usr/lib/sendmail -Ac -q15m
/usr/lib/sendmail -bd -q15m

sendmail is NOT normally used interactively from the command line, usually mailx is invoked to read to to submit mail. There are other interface programs like mailx. It is possible to use a local command-line process running sendmail to send and receive email. IMO it is hard to use. A lot of others agree - why mailx was written.

So the architecture is

  1. a sendmail process to handle submitted emails
  2. a sendmail process to deal with smtp - sending and receiving email locally and on the network.
  3. mailx -and friends- for email users to read email and to send email. mailx is also often used in shell scripts to send email.

I honestly could not tell what you were asking, it seemed convoluted to me.
So, this is my attempt at an answer. The 2 sendmail process design is for Solaris 10 and newer -Solaris 9 is different just one process.

PS: do NOT directly edit one of the .cf files. A "feature" of sendmail is that it requires writing M4 preprocessor text which is then fed to M4 to generate the .cf file. There is a "makefile" for this process in the /etc/mail directory tree. Eric Allman wrote sendmail long ago - there are good books from O'Reilly on all of the complexities and nuances of sendmail - and there are many complexities.

1 Like

1) it is Sun's tradition to ship a sendmail.cf with the relayhost set to mailhost.
Then you only need to define mailhost in the hosts file (or, even easier, in the naming service e.g. DNS).
1a) mailx, when delivering E-mail, spawns a sendmail that reads submit.cf.
The shipped submit.cf tells to deliver to port 25 on localhost.
2) there is also a sendmail daemon process that reads sendmail.cf and listens to port 25.
--
If you want mailx to deliver mail to mailhost without the sendmail daemon, you must define mailhost in submit.cf. Placing mailhost in the DS line should do it. (I would not go through the m4 hassle.)

1 Like

Hi all,

Thanks for sharing the information above.

So can i said that , there are generally 3 processes involved

-mailx
-sendmail (for mailsubmission)
-sendmail (for mail relay)

Right ?

If i have set a mailhost in /etc/hosts on another server (e.g. ServerA) (-- p.s. i did not change anything in submit.cf)

is the path travel
a) mailx -> sendmail (mail submission) -> sendmail (local) --> mailhost (server A)?
or
b) mailx -> sendmail (mail submission) -> mailhost (server A)

Regards,
Noob

Yes, right. (Well, a later sendmail daemon runs as two processes, one root and one non-root.)

a) mailx -> sendmail (mail submission) -> sendmail (local) -> mailhost (server A)
                  ^ default submit.cf                  ^ default sendmail.cf has mailhost

b) mailx -> sendmail (mail submission) -> mailhost (server A)
                  ^ mailhost in submit.cf
1 Like

Hi MadeInGermany,

Thanks for the reply.

In that case of b), do we still need to startup sendmail service on the local machine ?

Regards,
Noob

b) No sendmail service/daemon needed.

1 Like

:eek:hi all,

sorry for bring up this thread.
I happen to encounter this setup below

 
 disabled       Jan_23   svc:/network/sendmail-client:default
online         Jan_23   svc:/network/smtp:sendmail

 ps -ef | grep sendmail
    root  2838  2101   0   Jan 23 ?           0:49 /usr/lib/sendmail -bl -q15m
  oracle 25537  9002   0 20:42:07 pts/2       0:00 grep sendmail
 

There is also no mailhost set in the /etc/hosts nor DNS (using nslookup) and yet I can still send out email using mailx from that server.

There is a local sendmail daemon listening at port 25 though.

Does it means

1) when sendmail-client service is disabled, it just means that there will be no daemon to push the mclientqueue but mailx will still spawn a sendmail process as a msp and read the submit.cf

2) having no mailhost define in /etc/hosts and dns, and a sendmail daemon (MTA) listening at local port 25, can I say that the local sendmail MTA directly
resolve the next hop to the actual mailserver of the recipient / sending out without going through a relay ?

Regards,
Noob:eek::confused::confused: